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 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Itstructure\GridView\Filters;
4
5
use Itstructure\GridView\Traits\Configurable;
6
7
/**
8
 * Class BaseFilter.
9
 * @package Itstructure\GridView\Filters
10
 */
11
abstract class BaseFilter
12
{
13
    use Configurable;
14
15
    /**
16
     * @var string
17
     */
18
    protected $name = '';
19
20
    /**
21
     * @var string
22
     */
23
    protected $value;
24
25
    /**
26
     * @var mixed
27
     */
28
    protected $data = [];
29
30
    /**
31
     * BaseFilter constructor.
32
     * @param $config
33
     */
34
    public function __construct($config = [])
35
    {
36
        $this->loadConfig($config);
37
        $this->setValue();
38
    }
39
40
    /**
41
     * Render filters template.
42
     */
43
    abstract public function render(): string;
44
45
    public function setValue(): void
46
    {
47
        $this->value = request()->input('filters.' . $this->getName(), $this->value);
48
    }
49
50
    /**
51
     * @return mixed
52
     */
53
    protected function getValue()
54
    {
55
        return $this->value ?? null;
56
    }
57
58
    /**
59
     * @return string
60
     */
61
    protected function getName()
62
    {
63
        return $this->name;
64
    }
65
66
    /**
67
     * @return mixed
68
     */
69
    protected function getData()
70
    {
71
        return $this->data;
72
    }
73
}
74