FieldView   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 96
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 9
eloc 16
c 1
b 0
f 0
dl 0
loc 96
ccs 20
cts 20
cp 1
rs 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 4 1
A __construct() 0 4 1
A getListField() 0 3 1
A getSort() 0 3 1
A getLabel() 0 3 1
A getValue() 0 3 1
A getRow() 0 3 1
A isSortable() 0 3 1
A getId() 0 3 1
1
<?php
2
3
namespace Povs\ListerBundle\View;
4
5
use Povs\ListerBundle\Mapper\ListField;
6
use Povs\ListerBundle\Mixin\OptionsTrait;
7
8
/**
9
 * @author Povilas Margaiatis <[email protected]>
10
 */
11
class FieldView implements ViewInterface
12
{
13
    use OptionsTrait;
14
15
    /**
16
     * @var ListField
17
     */
18
    private $listField;
19
20
    /**
21
     * @var RowView
22
     */
23
    private $rowView;
24
25
    /**
26
     * @var mixed
27
     */
28
    private $value;
29
30
    /**
31
     * FieldView constructor.
32
     *
33
     * @param ListField $listField
34
     */
35 9
    public function __construct(ListField $listField)
36
    {
37 9
        $this->listField = $listField;
38 9
        $this->initOptions($listField->getOption(ListField::OPTION_VIEW_OPTIONS, []));
0 ignored issues
show
Bug introduced by
It seems like $listField->getOption(Po..._VIEW_OPTIONS, array()) can also be of type Doctrine\Common\Collections\T and null; however, parameter $options of Povs\ListerBundle\View\FieldView::initOptions() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

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

38
        $this->initOptions(/** @scrutinizer ignore-type */ $listField->getOption(ListField::OPTION_VIEW_OPTIONS, []));
Loading history...
39
    }
40
41
    /**
42
     * @return RowView
43
     */
44 2
    public function getRow(): RowView
45
    {
46 2
        return $this->rowView;
47
    }
48
49
    /**
50
     * @return string
51
     */
52 1
    public function getId(): string
53
    {
54 1
        return $this->listField->getId();
55
    }
56
57
    /**
58
     * @return mixed
59
     */
60 2
    public function getValue()
61
    {
62 2
        return $this->value;
63
    }
64
65
    /**
66
     * @return bool
67
     */
68 1
    public function isSortable(): bool
69
    {
70 1
        return $this->listField->getOption(ListField::OPTION_SORTABLE);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->listField-...Field::OPTION_SORTABLE) returns the type Doctrine\Common\Collections\T|null which is incompatible with the type-hinted return boolean.
Loading history...
71
    }
72
73
    /**
74
     * @return string|null DESC|ASC
75
     */
76 1
    public function getSort(): ?string
77
    {
78 1
        return $this->listField->getOption(ListField::OPTION_SORT_VALUE);
79
    }
80
81
    /**
82
     * @return string
83
     */
84 1
    public function getLabel(): string
85
    {
86 1
        return $this->listField->getOption(ListField::OPTION_LABEL);
87
    }
88
89
    /**
90
     * @internal
91
     * @return ListField
92
     */
93 2
    public function getListField(): ListField
94
    {
95 2
        return $this->listField;
96
    }
97
98
    /**
99
     * @internal
100
     * @param RowView $rowView
101
     * @param mixed   $value
102
     */
103 4
    public function init(RowView $rowView, $value): void
104
    {
105 4
        $this->rowView = $rowView;
106 4
        $this->value = $value;
107
    }
108
}
109