| Total Complexity | 7 |
| Total Lines | 58 |
| Duplicated Lines | 0 % |
| Coverage | 94.12% |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types=1); |
||
| 23 | abstract class AbstractObject implements ObjectInterface |
||
| 24 | { |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @var string[] |
||
| 28 | */ |
||
| 29 | protected const IGNORE_FIELDS = []; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @var array |
||
| 33 | */ |
||
| 34 | protected const FIELD_ALIASES = []; |
||
| 35 | |||
| 36 | /** |
||
| 37 | * {@inheritDoc} |
||
| 38 | */ |
||
| 39 | 8 | public function toArray() : array |
|
| 40 | { |
||
| 41 | 8 | $fields = $this->getFields(); |
|
| 42 | |||
| 43 | array_walk_recursive($fields, function (&$value) { |
||
| 44 | 8 | if ($value instanceof ObjectInterface) { |
|
| 45 | $value = $value->toArray(); |
||
| 46 | } |
||
| 47 | 8 | }); |
|
| 48 | |||
| 49 | 8 | return $fields; |
|
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * Gets all filled fields of the object |
||
| 54 | * |
||
| 55 | * @return array |
||
| 56 | */ |
||
| 57 | 8 | protected function getFields() : array |
|
| 81 | } |
||
| 82 | } |
||
| 83 |