| Conditions | 6 |
| Paths | 11 |
| Total Lines | 22 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 42 |
| Changes | 0 | ||
| 1 | <?php |
||
| 28 | public function __toArray() |
||
| 29 | { |
||
| 30 | $dto = array(); |
||
| 31 | try { |
||
| 32 | $reflectionClass = new \ReflectionClass($this); |
||
| 33 | $properties = $reflectionClass->getProperties(\ReflectionProperty::IS_PUBLIC); |
||
| 34 | if (count($properties) > 0) { |
||
| 35 | /** @var \ReflectionProperty $property */ |
||
| 36 | foreach ($properties as $property) { |
||
| 37 | $value = $property->getValue($this); |
||
| 38 | if(is_object($value) && method_exists($value, 'toArray')) { |
||
| 39 | $dto[$property->getName()] = $value->toArray(); |
||
| 40 | } else { |
||
| 41 | $dto[$property->getName()] = $property->getValue($this); |
||
| 42 | } |
||
| 43 | } |
||
| 44 | } |
||
| 45 | } catch (\Exception $e) { |
||
| 46 | Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR); |
||
| 47 | } |
||
| 48 | return $dto; |
||
| 49 | } |
||
| 50 | |||
| 74 | } |