Total Complexity | 2 |
Total Lines | 32 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
10 | trait JsonSerializableTrait |
||
11 | { |
||
12 | /** |
||
13 | * Returns class properties as an array. |
||
14 | * |
||
15 | * @return array |
||
16 | */ |
||
17 | abstract public function asArray(): array; |
||
18 | |||
19 | /** |
||
20 | * Specify data which should be serialized to JSON. |
||
21 | * |
||
22 | * Serializes the object to a value that can be serialized natively by `json_encode()`. |
||
23 | * |
||
24 | * @return mixed returns data which can be serialized by `json_encode()`, |
||
25 | * which is a value of any type other than a `resource` |
||
26 | * |
||
27 | * @see https://php.net/manual/en/jsonserializable.jsonserialize.php JsonSerializable::jsonSerialize |
||
28 | */ |
||
29 | public function jsonSerialize() |
||
30 | { |
||
31 | return $this->asArray(); |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * @return array |
||
36 | * |
||
37 | * @internal |
||
38 | */ |
||
39 | public function __debugInfo() |
||
42 | } |
||
43 | } |
||
44 |