| Conditions | 5 | 
| Paths | 4 | 
| Total Lines | 22 | 
| Code Lines | 13 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Tests | 12 | 
| CRAP Score | 5 | 
| Changes | 0 | ||
| 1 | <?php  | 
            ||
| 14 | 19 | public function toArray(): array  | 
            |
| 15 |     { | 
            ||
| 16 | 19 | $array = [];  | 
            |
| 17 | |||
| 18 | 19 | $reflection = new ReflectionClass($this);  | 
            |
| 19 | 19 | $properties = $reflection->getProperties();  | 
            |
| 20 | |||
| 21 | 19 |         foreach ($properties as $property) { | 
            |
| 22 | 18 |             if ($property->getValue($this)) { | 
            |
| 23 | 16 | $value = $property->getValue($this);  | 
            |
| 24 | if (  | 
            ||
| 25 | 16 | is_object($value) &&  | 
            |
| 26 | 16 | method_exists($value, 'toArray')  | 
            |
| 27 |                 ) { | 
            ||
| 28 | 6 | $array[$property->getName()] = $value->toArray();  | 
            |
| 29 |                 } else { | 
            ||
| 30 | 15 | $array[$property->getName()] = $property->getValue($this);  | 
            |
| 31 | }  | 
            ||
| 32 | }  | 
            ||
| 33 | }  | 
            ||
| 34 | |||
| 35 | 19 | return $array;  | 
            |
| 36 | }  | 
            ||
| 38 |