added jsonserializable interface / trait
This commit is contained in:
12
core/General/JsonSerializable.php
Normal file
12
core/General/JsonSerializable.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace ManiaControl\General;
|
||||
|
||||
/**
|
||||
* Object implementing this Interface has a toJson() Method
|
||||
*
|
||||
* @package ManiaControl\General
|
||||
*/
|
||||
interface JsonSerializable {
|
||||
public function toJson();
|
||||
}
|
14
core/General/JsonSerializeTrait.php
Normal file
14
core/General/JsonSerializeTrait.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace ManiaControl\General;
|
||||
|
||||
/**
|
||||
* Class DumpTrait Trait for Implementing the Methods for the JsonSerializeable Interface
|
||||
*
|
||||
* @package ManiaControl\General
|
||||
*/
|
||||
trait JsonSerializeTrait {
|
||||
public function toJson(){
|
||||
return json_encode(get_object_vars($this));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user