Total Complexity | 6 |
Total Lines | 27 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
7 | abstract class Dto implements \JsonSerializable |
||
8 | { |
||
9 | public function jsonSerialize() |
||
10 | { |
||
11 | return $this->serialize(get_object_vars($this)); |
||
12 | } |
||
13 | |||
14 | private function serialize(array $properties) |
||
15 | { |
||
16 | foreach ($properties as $key => $property){ |
||
17 | if(is_object($property)){ |
||
18 | $params[$this->camelToSnake($key)] = $this->serialize(get_object_vars($property)); |
||
19 | }else { |
||
20 | $params[$this->camelToSnake($key)] = $property; |
||
21 | } |
||
22 | } |
||
23 | return $params; |
||
|
|||
24 | } |
||
25 | |||
26 | private function camelToSnake($input) |
||
29 | } |
||
30 | |||
31 | public function toArray():array |
||
34 | } |
||
35 | } |
||
36 |