added jsonserializable interface / trait
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace ManiaControl\General;
|
||||
|
||||
/**
|
||||
* Object implementing this Interface has a toJson() Method
|
||||
*
|
||||
* @package ManiaControl\General
|
||||
*/
|
||||
interface JsonSerializable {
|
||||
public function toJson();
|
||||
}
|
||||
@@ -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