BaseFilter::getName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 1
b 0
f 1
1
<?php
2
3
namespace ChurakovMike\EasyGrid\Filters;
4
5
use ChurakovMike\EasyGrid\Traits\Configurable;
6
7
/**
8
 * Class BaseFilter.
9
 * @package ChurakovMike\EasyGrid\Filters
10
 *
11
 * @property string $name
12
 * @property string $value
13
 */
14
abstract class BaseFilter
15
{
16
    use Configurable;
17
18
    /**
19
     * @var string $name
20
     */
21
    public $name;
22
23
    /**
24
     * @var string $value
25
     */
26
    public $value;
27
28
    /**
29
     * BaseFilter constructor.
30
     * @param $config
31
     */
32
    public function __construct($config)
33
    {
34
        $this->loadConfig($config);
35
        $this->setValue();
36
    }
37
38
    /**
39
     * Render filters template.
40
     */
41
    public function render(): string
42
    {
43
    }
0 ignored issues
show
Bug Best Practice introduced by
In this branch, the function will implicitly return null which is incompatible with the type-hinted return string. Consider adding a return statement or allowing null as return value.

For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example:

interface ReturnsInt {
    public function returnsIntHinted(): int;
}

class MyClass implements ReturnsInt {
    public function returnsIntHinted(): int
    {
        if (foo()) {
            return 123;
        }
        // here: null is implicitly returned
    }
}
Loading history...
44
45
    /**
46
     * @return mixed
47
     */
48
    public function getValue()
49
    {
50
        return $this->value ?? '';
51
    }
52
53
    public function setValue()
54
    {
55
        $this->value = request()->input('filters.' . $this->getName(), $this->value);
56
    }
57
58
    /**
59
     * Return filter name.
60
     *
61
     * @return string|null
62
     */
63
    public function getName()
64
    {
65
        return $this->name;
66
    }
67
}
68