Total Complexity | 5 |
Total Lines | 25 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
19 | trait Iterator |
||
20 | { |
||
21 | /** |
||
22 | * Get all properties in array form. |
||
23 | * |
||
24 | * @return array<mixed> |
||
25 | */ |
||
26 | public function toArray(): array |
||
27 | { |
||
28 | $props = $this->getProperties(); |
||
|
|||
29 | foreach ($props as $key => $value) { |
||
30 | if ($value instanceof Model) { |
||
31 | $props[$key] = $value->toArray(); |
||
32 | } |
||
33 | if ($value instanceof Collection) { |
||
34 | $props[$key] = $value->toArray(); |
||
35 | } |
||
36 | } |
||
37 | |||
38 | return $props; |
||
39 | } |
||
40 | |||
41 | public function getIterator(): \Traversable |
||
44 | } |
||
45 | } |
||
46 |