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

DatagridReader::configureFields()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 3
nc 3
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace KunicMarko\SonataAnnotationBundle\Reader;
6
7
use KunicMarko\SonataAnnotationBundle\Annotation\DatagridField;
8
use Sonata\AdminBundle\Datagrid\DatagridMapper;
9
10
/**
11
 * @author Marko Kunic <[email protected]>
12
 */
13
class DatagridReader
14
{
15
    use AnnotationReaderTrait;
16
17
    public function configureFields(\ReflectionClass $class, DatagridMapper $datagridMapper): void
18
    {
19
        foreach ($class->getProperties() as $property) {
20
            if ($annotation = $this->getPropertyAnnotation($property, DatagridField::class)) {
21
                $datagridMapper->add($property->getName(), ...$annotation->getSettings());
0 ignored issues
show
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
                $datagridMapper->add($property->getName(), ...$annotation->/** @scrutinizer ignore-call */ getSettings());
Loading history...
Bug introduced by
$annotation->getSettings() is expanded, but the parameter $type of Sonata\AdminBundle\Datagrid\DatagridMapper::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
                $datagridMapper->add($property->getName(), /** @scrutinizer ignore-type */ ...$annotation->getSettings());
Loading history...
22
            }
23
        }
24
    }
25
}
26