| Total Complexity | 5 |
| Total Lines | 22 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | trait Iterator{ |
||
| 8 | /** |
||
| 9 | * Get all properties in array form |
||
| 10 | * @return array<mixed> |
||
| 11 | */ |
||
| 12 | public function toArray(): array |
||
| 13 | { |
||
| 14 | $props = $this->getProperties(); |
||
|
|
|||
| 15 | foreach ($props as $key => $value) { |
||
| 16 | if ($value instanceof Model) { |
||
| 17 | $props[$key] = $value->toArray(); |
||
| 18 | } |
||
| 19 | if ($value instanceof Collection) { |
||
| 20 | $props[$key] = $value->toArray(); |
||
| 21 | } |
||
| 22 | } |
||
| 23 | return $props; |
||
| 24 | } |
||
| 25 | |||
| 26 | public function getIterator(): \Traversable |
||
| 29 | } |
||
| 30 | } |