1 | <?php |
||
7 | final class StringMatchFilter extends Filter |
||
8 | { |
||
9 | const LIKE = 'LIKE'; |
||
10 | const STARTS_WITH = 'STARTS_WITH'; |
||
11 | const ENDS_WITH = 'ENDS_WITH'; |
||
12 | const REGEXP = 'REGEXP'; |
||
13 | |||
14 | const OPERATORS = [ |
||
15 | self::LIKE, |
||
16 | self::STARTS_WITH, |
||
17 | self::ENDS_WITH, |
||
18 | self::REGEXP, |
||
19 | ]; |
||
20 | |||
21 | /** |
||
22 | * @var string |
||
23 | */ |
||
24 | private $field; |
||
25 | |||
26 | /** |
||
27 | * @var FilterValue |
||
28 | */ |
||
29 | private $value; |
||
30 | |||
31 | /** |
||
32 | * @var string |
||
33 | */ |
||
34 | private $operator; |
||
35 | |||
36 | /** |
||
37 | * StringMatchFilter constructor. |
||
38 | * @param string $field |
||
39 | * @param FilterValue|null $value |
||
40 | * @param string $operator |
||
41 | */ |
||
42 | public function __construct(string $field, FilterValue $value = null, string $operator = self::LIKE) |
||
48 | |||
49 | /** |
||
50 | * @param string $field |
||
51 | * @param string $value |
||
52 | * @param string $operator |
||
53 | * @return StringMatchFilter |
||
54 | */ |
||
55 | public static function createFromValue(string $field, string $value, string $operator = self::LIKE) |
||
63 | |||
64 | /** |
||
65 | * @inheritDoc |
||
66 | */ |
||
67 | public function getField(): string |
||
71 | |||
72 | /** |
||
73 | * @inheritDoc |
||
74 | */ |
||
75 | public function getValue() |
||
79 | |||
80 | /** |
||
81 | * @return FilterValue|null |
||
82 | */ |
||
83 | public function getFilterValue() |
||
87 | |||
88 | /** |
||
89 | * @return string |
||
90 | */ |
||
91 | public function getOperator(): ?string |
||
95 | |||
96 | /** |
||
97 | * @inheritDoc |
||
98 | */ |
||
99 | public function getType(): string |
||
103 | |||
104 | /** |
||
105 | * @inheritDoc |
||
106 | */ |
||
107 | public function jsonSerialize(): array |
||
126 | } |
||
127 |