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.

FilterBase::getAlias()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 3
c 0
b 0
f 0
nc 2
nop 0
dl 0
loc 7
ccs 0
cts 3
cp 0
crap 6
rs 10
1
<?php
2
3
namespace SleepingOwl\Admin\Display\Filter;
4
5
use Closure;
6
use Illuminate\Support\Str;
7
use SleepingOwl\Admin\Contracts\Display\Extension\FilterInterface;
8
9
abstract class FilterBase implements FilterInterface
10
{
11
    /**
12
     * @var string
13
     */
14
    protected $name;
15
16
    /**
17
     * @var string
18
     */
19
    protected $alias;
20
21
    /**
22
     * @var string|\Closure|null
23
     */
24
    protected $title;
25
26
    /**
27
     * @var mixed
28
     */
29
    protected $value;
30
31
    /**
32
     * @param string $name
33
     * @param string|\Closure|null $title
34
     */
35
    public function __construct($name, $title = null)
36
    {
37
        $this->setName($name);
38
39
        if (! is_null($title)) {
40
            $this->setTitle($title);
41
        }
42
    }
43
44
    /**
45
     * Initialize filter.
46
     */
47
    public function initialize()
48
    {
49
        if (is_null($value = $this->getValue())) {
50
            $value = request()->input($this->getAlias());
51
        }
52
53
        $this->setValue($value);
54
    }
55
56
    /**
57
     * @return string
58
     */
59
    public function getName()
60
    {
61
        return $this->name;
62
    }
63
64
    /**
65
     * @param string $name
66
     *
67
     * @return $this
68
     */
69
    public function setName($name)
70
    {
71
        $this->name = $name;
72
73
        return $this;
74
    }
75
76
    /**
77
     * @return string
78
     */
79
    public function getAlias()
80
    {
81
        if (! $this->alias) {
82
            return $this->getName();
83
        }
84
85
        return $this->alias;
86
    }
87
88
    /**
89
     * @param string $alias
90
     *
91
     * @return $this
92
     */
93
    public function setAlias($alias)
94
    {
95
        $this->alias = $alias;
96
97
        return $this;
98
    }
99
100
    /**
101
     * @return string
102
     */
103
    public function getTitle()
104
    {
105
        if (is_null($this->title)) {
106
            return Str::studly($this->getAlias());
107
        }
108
109
        if (is_callable($this->title)) {
110
            return call_user_func($this->title, $this->getValue());
111
        }
112
113
        return strtr($this->title, [':value' => $this->getValue()]);
0 ignored issues
show
Bug introduced by
It seems like $this->title can also be of type Closure; however, parameter $str of strtr() does only seem to accept string, 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

113
        return strtr(/** @scrutinizer ignore-type */ $this->title, [':value' => $this->getValue()]);
Loading history...
114
    }
115
116
    /**
117
     * @param Closure|string $title
118
     *
119
     * @return $this
120
     */
121
    public function setTitle($title)
122
    {
123
        $this->title = $title;
124
125
        return $this;
126
    }
127
128
    /**
129
     * @return mixed
130
     */
131
    public function getValue()
132
    {
133
        return $this->value;
134
    }
135
136
    /**
137
     * @param mixed $value
138
     *
139
     * @return $this
140
     */
141
    public function setValue($value)
142
    {
143
        $this->value = $value;
144
145
        return $this;
146
    }
147
148
    /**
149
     * @return bool
150
     */
151
    public function isActive()
152
    {
153
        return ! is_null($this->getValue());
154
    }
155
}
156