Conditions | 7 |
Paths | 5 |
Total Lines | 23 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
16 | public function toArray(): array |
||
17 | { |
||
18 | $result = []; |
||
19 | |||
20 | $items = get_object_vars($this); |
||
21 | foreach ($items as $key => $item) { |
||
22 | if (is_array($item)) { |
||
23 | foreach ($item as $subKey => $subItem) { |
||
24 | if ($subItem instanceof ModelInterface) { |
||
25 | $result[$this->normalize($key)][$subKey] = $subItem->toArray(); |
||
26 | } else { |
||
27 | $result[$this->normalize($key)][$subKey] = $subItem; |
||
28 | } |
||
29 | } |
||
30 | } elseif ($item instanceof ModelInterface) { |
||
31 | $result[$this->normalize($key)] = $item->toArray(); |
||
32 | } elseif (!empty($item)) { |
||
33 | $result[$this->normalize($key)] = $item; |
||
34 | } |
||
35 | } |
||
36 | |||
37 | return $result; |
||
38 | } |
||
39 | |||
78 |