| Conditions | 4 |
| Paths | 4 |
| Total Lines | 19 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | 2 | public function toArray($except = []) |
|
| 17 | { |
||
| 18 | 2 | $result = []; |
|
| 19 | 2 | foreach ((new ReflectionClass($this))->getProperties() as $info) |
|
| 20 | { |
||
| 21 | 2 | $name = $info->name; |
|
| 22 | 2 | if (in_array($name, $except)) |
|
| 23 | { |
||
| 24 | 2 | continue; |
|
| 25 | } |
||
| 26 | 2 | $value = $this->$name; |
|
| 27 | 2 | if ($value instanceof self) |
|
| 28 | { |
||
| 29 | 1 | $value = $value->toArray(); |
|
| 30 | } |
||
| 31 | 2 | $result[$name] = $value; |
|
| 32 | } |
||
| 33 | 2 | return $result; |
|
| 34 | } |
||
| 35 | |||
| 37 |