Passed
Push — develop ( 355f63...51016a )
by Mathieu
02:23
created

DatagridField   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 12
dl 0
loc 51
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSettings() 0 7 1
A __construct() 0 11 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Neimheadh\SonataAnnotationBundle\Annotation\Sonata;
6
7
use Attribute;
8
use Neimheadh\SonataAnnotationBundle\Annotation\AbstractField;
9
use Neimheadh\SonataAnnotationBundle\Annotation\PositionAnnotationInterface;
10
use ReflectionException;
11
12
/**
13
 * Datagrid field annotation.
14
 *
15
 * Allow you to configure the datagrid for the annotated field.
16
 *
17
 * @Annotation
18
 * @Target("PROPERTY")
19
 *
20
 * @author Marko Kunic <[email protected]>
21
 * @author Mathieu Wambre <[email protected]>
22
 */
23
#[Attribute(Attribute::TARGET_PROPERTY)]
24
class DatagridField extends AbstractField implements PositionAnnotationInterface
25
{
26
27
    /**
28
     * Filtering options.
29
     *
30
     * @var array
31
     */
32
    public array $filterOptions = [];
33
34
    /**
35
     * Datagrid form field type options.
36
     *
37
     * @var array
38
     */
39
    public array $fieldOptions = [];
40
41
    /**
42
     * {@inheritDoc}
43
     *
44
     * @param array $filterOptions Filtering options.
45
     * @param array $fieldOptions  Datagrid form field type options.
46
     *
47
     * @throws ReflectionException
48
     */
49
    public function __construct(
50
        $type = null,
51
        array $fieldDescriptionOptions = [],
52
        ?int $position = null,
53
        array $filterOptions = [],
0 ignored issues
show
Unused Code introduced by
The parameter $filterOptions is not used and could be removed. ( Ignorable by Annotation )

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

53
        /** @scrutinizer ignore-unused */ array $filterOptions = [],

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
54
        array $fieldOptions = []
55
    ) {
56
        $this->filterOptions = $fieldOptions;
57
        $this->fieldOptions = $fieldOptions;
58
59
        parent::__construct($type, $fieldDescriptionOptions, $position);
60
    }
61
62
    /**
63
     * Get field settings.
64
     *
65
     * @return array
66
     */
67
    public function getSettings(): array
68
    {
69
        return [
70
            $this->type,
71
            $this->filterOptions,
72
            $this->fieldOptions,
73
            $this->fieldDescriptionOptions,
74
        ];
75
    }
76
77
}
78