1 | <?php |
||
8 | class iDokladFilter implements UrlExtensionInterface |
||
9 | { |
||
10 | const LESS_THEN = 'lt'; |
||
11 | |||
12 | const LESS_THEN_OR_EQUAL = 'lte'; |
||
13 | |||
14 | const GREATER_THEN = 'gt'; |
||
15 | |||
16 | const GREATER_THEN_OR_EQUAL = 'gte'; |
||
17 | |||
18 | const EQUAL = 'eq'; |
||
19 | |||
20 | const NOT_EQUAL = '!eq'; |
||
21 | |||
22 | const CONTAINS = 'ct'; |
||
23 | |||
24 | const NOT_CONTAINS = '!ct'; |
||
25 | |||
26 | const BETWEEN = 'between'; |
||
27 | |||
28 | const FILTER_TYPE_AND = 'and'; |
||
29 | |||
30 | const FILTER_TYPE_OR = 'or'; |
||
31 | |||
32 | public static $operators = [ |
||
33 | self::LESS_THEN, |
||
34 | self::LESS_THEN_OR_EQUAL, |
||
35 | self::GREATER_THEN, |
||
36 | self::GREATER_THEN_OR_EQUAL, |
||
37 | self::EQUAL, |
||
38 | self::NOT_EQUAL, |
||
39 | self::CONTAINS, |
||
40 | self::NOT_CONTAINS, |
||
41 | self::BETWEEN, |
||
42 | ]; |
||
43 | |||
44 | protected $parts = []; |
||
45 | |||
46 | protected $type = self::FILTER_TYPE_AND; |
||
47 | |||
48 | /** |
||
49 | * @param string $property |
||
50 | * @param string $operator |
||
51 | * @param string $value |
||
52 | * |
||
53 | * @throws \InvalidArgumentException |
||
54 | * |
||
55 | * @return $this |
||
56 | */ |
||
57 | public function filter(string $property, string $operator, string $value): self |
||
76 | |||
77 | /** |
||
78 | * @param string $type |
||
79 | * |
||
80 | * @throws \InvalidArgumentException |
||
81 | * |
||
82 | * @return iDokladFilter |
||
83 | */ |
||
84 | public function filterType(string $type): self |
||
98 | |||
99 | /** |
||
100 | * Return key => value associative array of HTTP GET parameters. |
||
101 | * |
||
102 | * @return array |
||
103 | * |
||
104 | * @internal |
||
105 | */ |
||
106 | public function getHttpQuery(): array |
||
117 | |||
118 | /** |
||
119 | * @param string $operator |
||
120 | * |
||
121 | * @return bool |
||
122 | */ |
||
123 | protected function isValidOperator(string $operator): bool |
||
127 | } |
||
128 |