Completed
Push — 1.x ( d1a99d...be31ef )
by Marko
02:10
created

ShowReader   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 7
dl 0
loc 26
c 0
b 0
f 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
C configureFields() 0 22 7
1
<?php
2
3
declare(strict_types=1);
4
5
namespace KunicMarko\SonataAnnotationBundle\Reader;
6
7
use KunicMarko\SonataAnnotationBundle\Annotation\ShowAssociationField;
8
use KunicMarko\SonataAnnotationBundle\Annotation\ShowField;
9
use Sonata\AdminBundle\Show\ShowMapper;
10
11
/**
12
 * @author Marko Kunic <[email protected]>
13
 */
14
class ShowReader
15
{
16
    use AnnotationReaderTrait;
17
18
    public function configureFields(\ReflectionClass $class, ShowMapper $showMapper): void
19
    {
20
        foreach ($class->getProperties() as $property) {
21
            foreach ($this->getPropertyAnnotations($property) as $annotation) {
22
                if ($annotation instanceof ShowAssociationField) {
23
                    $showMapper->add(
24
                        $property->getName() . '.' . $annotation->field,
25
                        ...$annotation->getSettings()
0 ignored issues
show
Bug introduced by
$annotation->getSettings() is expanded, but the parameter $type of Sonata\AdminBundle\Show\ShowMapper::add() does not expect variable arguments. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

25
                        /** @scrutinizer ignore-type */ ...$annotation->getSettings()
Loading history...
26
                    );
27
28
                    continue;
29
                }
30
31
                if ($annotation instanceof ShowField) {
32
                    $showMapper->add($property->getName(), ...$annotation->getSettings());
33
                }
34
            }
35
        }
36
37
        foreach ($class->getMethods() as $method) {
38
            if ($annotation = $this->getMethodAnnotation($method, ShowField::class)) {
39
                $showMapper->add($method->getName(), ...$annotation->getSettings());
40
            }
41
        }
42
    }
43
}
44