Total Complexity | 7 |
Total Lines | 86 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
16 | class FilterParam |
||
17 | { |
||
18 | /** |
||
19 | * @var string |
||
20 | */ |
||
21 | public $param; |
||
22 | /** |
||
23 | * @var string |
||
24 | */ |
||
25 | public $operator; |
||
26 | /** |
||
27 | * @var string|null |
||
28 | */ |
||
29 | public $sqlOperator; |
||
30 | /** |
||
31 | * @var mixed |
||
32 | */ |
||
33 | public $value; |
||
34 | |||
35 | /** |
||
36 | * FilterParam constructor. |
||
37 | * |
||
38 | * @param string $param |
||
39 | * @param string $operator |
||
40 | * @param $value |
||
41 | */ |
||
42 | 2 | public function __construct(string $param, string $operator, $value) |
|
43 | { |
||
44 | 2 | $this->param = $param; |
|
45 | 2 | $this->operator = $operator; |
|
46 | 2 | $this->sqlOperator = Filter::$allowedOperators[$operator]; |
|
47 | 2 | $this->value = $value; |
|
48 | 2 | } |
|
49 | |||
50 | /** |
||
51 | * @return bool |
||
52 | */ |
||
53 | 1 | public function isWhere(): bool |
|
54 | { |
||
55 | 1 | return \in_array($this->operator, [ |
|
56 | Filter::PARAM_EQ, |
||
57 | Filter::PARAM_GT, |
||
58 | Filter::PARAM_GTE, |
||
59 | Filter::PARAM_LT, |
||
60 | Filter::PARAM_LTE, |
||
61 | ], true); |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * @return bool |
||
66 | */ |
||
67 | 1 | public function isWhereIn(): bool |
|
68 | { |
||
69 | 1 | return Filter::PARAM_IN === $this->operator; |
|
70 | } |
||
71 | |||
72 | /** |
||
73 | * @return bool |
||
74 | */ |
||
75 | 1 | public function isWhereLike(): bool |
|
78 | } |
||
79 | |||
80 | /** |
||
81 | * @return bool |
||
82 | */ |
||
83 | 1 | public function isWhereNotIn(): bool |
|
86 | } |
||
87 | |||
88 | /** |
||
89 | * @return bool |
||
90 | */ |
||
91 | 1 | public function isWhereNotNull(): bool |
|
94 | } |
||
95 | |||
96 | /** |
||
97 | * @return bool |
||
98 | */ |
||
99 | 1 | public function isWhereNull(): bool |
|
104 |