FilterOperation   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 94
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
lcom 0
cbo 0
dl 0
loc 94
ccs 20
cts 20
cp 1
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A getField() 0 4 1
A setField() 0 5 1
A getValue() 0 4 1
A setValue() 0 5 1
A getOperator() 0 4 1
A setOperator() 0 5 1
1
<?php
2
3
namespace Nayjest\Querying\Operation;
4
5
/**
6
 * DataProvider operation for filtering rows.
7
 */
8
class FilterOperation implements OperationInterface{
9
10
    const OPERATOR_LIKE = 'like';
11
    const OPERATOR_STR_STARTS_WITH = 'str_starts_with';
12
    const OPERATOR_STR_ENDS_WITH = 'str_ends_with';
13
    const OPERATOR_STR_CONTAINS = 'str_contains';
14
    const OPERATOR_EQ = '=';
15
    const OPERATOR_NOT_EQ = '<>';
16
    const OPERATOR_GT = '>';
17
    const OPERATOR_LT = '<';
18
    const OPERATOR_LTE = '<=';
19
    const OPERATOR_GTE = '>=';
20
21
    protected $field;
22
23
    protected $value;
24
25
    protected $operator;
26
27
    /**
28
     * Constructor.
29
     *
30
     * @param string|null $field name of data field to filter rows by its value
31
     * @param string|null $operator
32
     * @param mixed $value
33
     */
34 3
    public function __construct(
35
        $field = null,
36
        $operator = self::OPERATOR_EQ,
37
        $value = null
38
    ) {
39 3
        $this->setField($field);
40 3
        $this->setValue($value);
41 3
        $this->setOperator($operator);
42 3
    }
43
44
    /**
45
     * Returns name of data field to filter rows by its value.
46
     *
47
     * @return string
48
     */
49 3
    public function getField()
50
    {
51 3
        return $this->field;
52
    }
53
54
    /**
55
     * Sets name of data field to filter rows by its value.
56
     *
57
     * @param $field
58
     * @return $this
59
     */
60 3
    public function setField($field)
61
    {
62 3
        $this->field = $field;
63 3
        return $this;
64
    }
65
66
    /**
67
     * @return mixed
68
     */
69 3
    public function getValue()
70
    {
71 3
        return $this->value;
72
    }
73
74
    /**
75
     * @param mixed $value
76
     * @return $this
77
     */
78 3
    public function setValue($value)
79
    {
80 3
        $this->value = $value;
81 3
        return $this;
82
    }
83
84
    /**
85
     * @return string
86
     */
87 3
    public function getOperator()
88
    {
89 3
        return $this->operator;
90
    }
91
92
    /**
93
     * @param $operator
94
     * @return $this
95
     */
96 3
    public function setOperator($operator)
97
    {
98 3
        $this->operator = $operator;
99 3
        return $this;
100
    }
101
}
102