Total Complexity | 9 |
Total Lines | 39 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
14 | class ExportReader |
||
15 | { |
||
16 | use AnnotationReaderTrait; |
||
17 | |||
18 | public function getFields(\ReflectionClass $class): array |
||
19 | { |
||
20 | $fields = []; |
||
21 | |||
22 | foreach ($class->getProperties() as $property) { |
||
23 | foreach ($this->getPropertyAnnotations($property) as $annotation) { |
||
24 | if ($annotation instanceof ExportAssociationField) { |
||
25 | $fieldName = $property->getName() . '.' . $annotation->field; |
||
26 | |||
27 | $fields[$annotation->label ?? $fieldName] = $fieldName; |
||
28 | continue; |
||
29 | } |
||
30 | |||
31 | if ($annotation instanceof ExportField) { |
||
32 | $fields[$annotation->label ?? $property->getName()] = $property->getName(); |
||
33 | } |
||
34 | } |
||
35 | } |
||
36 | |||
37 | foreach ($class->getMethods() as $method) { |
||
38 | if ($annotation = $this->getMethodAnnotation($method, ExportField::class)) { |
||
39 | $fields[$annotation->label ?? $method->getName()] = $method->getName(); |
||
40 | } |
||
41 | } |
||
42 | |||
43 | return $fields; |
||
44 | } |
||
45 | |||
46 | public function getFormats(\ReflectionClass $class): array |
||
53 | } |
||
54 | } |
||
55 |