Completed
Push — 1.x ( 8bcf66...54c417 )
by Marko
03:54
created

ShowReader::configureFields()   B

Complexity

Conditions 5
Paths 9

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 8.8571
c 0
b 0
f 0
cc 5
eloc 6
nc 9
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace KunicMarko\SonataAnnotationBundle\Reader;
6
7
use KunicMarko\SonataAnnotationBundle\Annotation\ShowField;
8
use Sonata\AdminBundle\Show\ShowMapper;
9
10
/**
11
 * @author Marko Kunic <[email protected]>
12
 */
13
class ShowReader
14
{
15
    use AnnotationReaderTrait;
16
17
    public function configureFields(\ReflectionClass $class, ShowMapper $showMapper): void
18
    {
19
        foreach ($class->getProperties() as $property) {
20
            if ($annotation = $this->getPropertyAnnotation($property, ShowField::class)) {
21
                $showMapper->add($property->getName(), ...$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

21
                $showMapper->add($property->getName(), /** @scrutinizer ignore-type */ ...$annotation->getSettings());
Loading history...
Bug introduced by
The method getSettings() does not exist on KunicMarko\SonataAnnotat...ion\AnnotationInterface. It seems like you code against a sub-type of KunicMarko\SonataAnnotat...ion\AnnotationInterface such as KunicMarko\SonataAnnotat...nnotation\AbstractField. ( Ignorable by Annotation )

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

21
                $showMapper->add($property->getName(), ...$annotation->/** @scrutinizer ignore-call */ getSettings());
Loading history...
22
            }
23
        }
24
25
        foreach ($class->getMethods() as $method) {
26
            if ($annotation = $this->getMethodAnnotation($method, ShowField::class)) {
27
                $showMapper->add($method->getName(), ...$annotation->getSettings());
28
            }
29
        }
30
    }
31
}
32