BaseFilter   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 11
c 1
b 0
f 0
dl 0
loc 61
rs 10

5 Methods

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