Total Complexity | 9 |
Total Lines | 38 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php declare(strict_types=1); |
||
22 | abstract class AbstractAnnotation implements AnnotationInterface |
||
23 | { |
||
24 | |||
25 | /** |
||
26 | * {@inheritDoc} |
||
27 | */ |
||
28 | public function toArray() : array |
||
29 | { |
||
30 | $fields = $this->getFields(); |
||
31 | |||
32 | $result = []; |
||
33 | foreach ($fields as $field => $value) { |
||
34 | if (!is_array($value)) { |
||
35 | $result[$field] = ($value instanceof AnnotationInterface) ? $value->toArray() : $value; |
||
36 | continue; |
||
37 | } |
||
38 | |||
39 | foreach ($value as $key => $item) { |
||
40 | $result[$field][$key] = ($item instanceof AnnotationInterface) ? $item->toArray() : $item; |
||
41 | } |
||
42 | } |
||
43 | |||
44 | return $result; |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * @return array |
||
49 | */ |
||
50 | private function getFields() : array |
||
60 | } |
||
61 | } |
||
62 |