GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — analysis-rdw4o3 ( a6c473 )
by butschster
12:11
created

Range   A

Complexity

Total Complexity 14

Size/Duplication

Total Lines 132
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 38
dl 0
loc 132
rs 10
c 2
b 0
f 0
wmc 14

8 Methods

Rating   Name   Duplication   Size   Complexity  
A setFrom() 0 5 1
A getTo() 0 3 1
A getFrom() 0 3 1
A setInline() 0 5 1
A parseValue() 0 21 6
A initialize() 0 16 2
A toArray() 0 5 1
A setTo() 0 5 1
1
<?php
2
3
namespace SleepingOwl\Admin\Display\Column\Filter;
4
5
use SleepingOwl\Admin\Contracts\Display\Extension\ColumnFilterInterface;
6
7
class Range extends BaseColumnFilter
8
{
9
    /**
10
     * @var string
11
     */
12
    protected $view = 'column.filter.range';
13
14
    /**
15
     * @var bool
16
     */
17
    protected $inline = false;
18
19
    /**
20
     * @var ColumnFilterInterface|BaseColumnFilter
21
     */
22
    protected $from;
23
24
    /**
25
     * @var ColumnFilterInterface|BaseColumnFilter
26
     */
27
    protected $to;
28
29
    /**
30
     * Initialize column filter.
31
     */
32
    public function initialize()
33
    {
34
        parent::initialize();
35
36
        $this->setHtmlAttribute('data-type', 'range');
37
        $this->setHtmlAttribute('class', 'column-filter');
38
39
        if ($this->inline) {
40
            $this->setHtmlAttribute('class', 'inline');
41
        }
42
43
        $this->getFrom()->initialize();
44
        $this->getTo()->initialize();
45
46
        $this->getFrom()->removeHtmlAttribute('data-type');
0 ignored issues
show
Bug introduced by
The method removeHtmlAttribute() does not exist on SleepingOwl\Admin\Contra...n\ColumnFilterInterface. Since it exists in all sub-types, consider adding an abstract or default implementation to SleepingOwl\Admin\Contra...n\ColumnFilterInterface. ( Ignorable by Annotation )

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

46
        $this->getFrom()->/** @scrutinizer ignore-call */ removeHtmlAttribute('data-type');
Loading history...
47
        $this->getTo()->removeHtmlAttribute('data-type');
48
    }
49
50
    /**
51
     * @param $inline
52
     *
53
     * @return $this
54
     */
55
    public function setInline($inline)
56
    {
57
        $this->inline = $inline;
58
59
        return $this;
60
    }
61
62
    /**
63
     * @return ColumnFilterInterface|BaseColumnFilter
64
     */
65
    public function getFrom()
66
    {
67
        return $this->from;
68
    }
69
70
    /**
71
     * @param ColumnFilterInterface $from
72
     *
73
     * @return $this
74
     */
75
    public function setFrom(ColumnFilterInterface $from)
76
    {
77
        $this->from = $from;
78
79
        return $this;
80
    }
81
82
    /**
83
     * @return ColumnFilterInterface|BaseColumnFilter
84
     */
85
    public function getTo()
86
    {
87
        return $this->to;
88
    }
89
90
    /**
91
     * @param ColumnFilterInterface $to
92
     *
93
     * @return $this
94
     */
95
    public function setTo(ColumnFilterInterface $to)
96
    {
97
        $this->to = $to;
98
99
        return $this;
100
    }
101
102
    /**
103
     * @return array
104
     */
105
    public function toArray()
106
    {
107
        return parent::toArray() + [
108
            'from' => $this->getFrom(),
109
            'to' => $this->getTo(),
110
        ];
111
    }
112
113
    /**
114
     * @param mixed $range
115
     * @return array|mixed|null|void
116
     * @throws \SleepingOwl\Admin\Exceptions\FilterOperatorException
117
     */
118
    public function parseValue($range)
119
    {
120
        if (strpos($range, '::') === false) {
121
            return;
122
        }
123
124
        $from = $this->from->parseValue(explode('::', $range, 2)[0]);
125
        $to = $this->to->parseValue(explode('::', $range, 2)[1]);
126
127
        if (! empty($from) && ! empty($to)) {
128
            $this->setOperator('between');
129
130
            return [$from, $to];
131
        } elseif (! empty($from)) {
132
            $this->setOperator('greater_or_equal');
133
134
            return $from;
135
        } elseif (! empty($to)) {
136
            $this->setOperator('less_or_equal');
137
138
            return $to;
139
        }
140
    }
141
}
142