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