BaseFilter   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 2
Metric Value
eloc 9
c 2
b 0
f 2
dl 0
loc 52
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setValue() 0 3 1
A __construct() 0 4 1
A render() 0 2 1
A getValue() 0 3 1
A getName() 0 3 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