Passed
Push — master ( c9645e...37753a )
by Marcin
03:38
created

FilterParam::isWhereNull()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * Created by Marcin.
4
 * Date: 16.06.2018
5
 * Time: 19:17
6
 */
7
declare(strict_types=1);
8
9
namespace mrcnpdlk\Lib\UrlSearchParser\Criteria;
10
11
/**
12
 * Class FilterParam
13
 *
14
 * @package mrcnpdlk\Lib\UrlSearchParser\Criteria
15
 */
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
76
    {
77 1
        return Filter::PARAM_LIKE === $this->operator;
78
    }
79
80
    /**
81
     * @return bool
82
     */
83 1
    public function isWhereNotIn(): bool
84
    {
85 1
        return Filter::PARAM_NOTIN === $this->operator;
86
    }
87
88
    /**
89
     * @return bool
90
     */
91 1
    public function isWhereNotNull(): bool
92
    {
93 1
        return Filter::PARAM_NOTNULL === $this->operator;
94
    }
95
96
    /**
97
     * @return bool
98
     */
99 1
    public function isWhereNull(): bool
100
    {
101 1
        return Filter::PARAM_NULL === $this->operator;
102
    }
103
}
104