1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the Tarantool Client package. |
7
|
|
|
* |
8
|
|
|
* (c) Eugene Leonovich <[email protected]> |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Tarantool\Client\Schema; |
15
|
|
|
|
16
|
|
|
final class Criteria |
17
|
|
|
{ |
18
|
|
|
private $index = 0; |
19
|
|
|
private $key = []; |
20
|
|
|
private $limit = \PHP_INT_MAX & 0xffffffff; |
21
|
|
|
private $offset = 0; |
22
|
|
|
private $iteratorType = IteratorTypes::EQ; |
23
|
|
|
|
24
|
112 |
|
private function __construct() |
25
|
|
|
{ |
26
|
112 |
|
} |
27
|
|
|
|
28
|
4 |
|
public static function index($index) : self |
29
|
|
|
{ |
30
|
4 |
|
$self = new self(); |
31
|
4 |
|
$self->index = $index; |
32
|
|
|
|
33
|
4 |
|
return $self; |
34
|
|
|
} |
35
|
|
|
|
36
|
110 |
|
public function andIndex($index) : self |
37
|
|
|
{ |
38
|
110 |
|
$new = clone $this; |
39
|
110 |
|
$new->index = $index; |
40
|
|
|
|
41
|
110 |
|
return $new; |
42
|
|
|
} |
43
|
|
|
|
44
|
112 |
|
public function getIndex() |
45
|
|
|
{ |
46
|
112 |
|
return $this->index; |
47
|
|
|
} |
48
|
|
|
|
49
|
112 |
|
public static function key(array $key) : self |
50
|
|
|
{ |
51
|
112 |
|
$self = new self(); |
52
|
112 |
|
$self->key = $key; |
53
|
|
|
|
54
|
112 |
|
return $self; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function andKey(array $key) : self |
58
|
|
|
{ |
59
|
|
|
$new = clone $this; |
60
|
|
|
$new->key = $key; |
61
|
|
|
|
62
|
|
|
return $new; |
63
|
|
|
} |
64
|
|
|
|
65
|
112 |
|
public function getKey() : array |
66
|
|
|
{ |
67
|
112 |
|
return $this->key; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public static function limit(int $limit) : self |
71
|
|
|
{ |
72
|
|
|
$self = new self(); |
73
|
|
|
$self->limit = $limit; |
74
|
|
|
|
75
|
|
|
return $self; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
public function andLimit(int $limit) : self |
79
|
|
|
{ |
80
|
|
|
$new = clone $this; |
81
|
|
|
$new->limit = $limit; |
82
|
|
|
|
83
|
|
|
return $new; |
84
|
|
|
} |
85
|
|
|
|
86
|
112 |
|
public function getLimit() : int |
87
|
|
|
{ |
88
|
112 |
|
return $this->limit; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
public static function offset(int $offset) : self |
92
|
|
|
{ |
93
|
|
|
$self = new self(); |
94
|
|
|
$self->offset = $offset; |
95
|
|
|
|
96
|
|
|
return $self; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
public function andOffset(int $offset) : self |
100
|
|
|
{ |
101
|
|
|
$new = clone $this; |
102
|
|
|
$new->offset = $offset; |
103
|
|
|
|
104
|
|
|
return $new; |
105
|
|
|
} |
106
|
|
|
|
107
|
112 |
|
public function getOffset() : int |
108
|
|
|
{ |
109
|
112 |
|
return $this->offset; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
public static function eqIterator() : self |
113
|
|
|
{ |
114
|
|
|
$self = new self(); |
115
|
|
|
$self->iteratorType = IteratorTypes::EQ; |
116
|
|
|
|
117
|
|
|
return $self; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
public function andEqIterator() : self |
121
|
|
|
{ |
122
|
|
|
$new = clone $this; |
123
|
|
|
$new->iteratorType = IteratorTypes::EQ; |
124
|
|
|
|
125
|
|
|
return $new; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
public static function reqIterator() : self |
129
|
|
|
{ |
130
|
|
|
$self = new self(); |
131
|
|
|
$self->iteratorType = IteratorTypes::REQ; |
132
|
|
|
|
133
|
|
|
return $self; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
public function andReqIterator() : self |
137
|
|
|
{ |
138
|
|
|
$new = clone $this; |
139
|
|
|
$new->iteratorType = IteratorTypes::REQ; |
140
|
|
|
|
141
|
|
|
return $new; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
public static function allIterator() : self |
145
|
|
|
{ |
146
|
|
|
$self = new self(); |
147
|
|
|
$self->iteratorType = IteratorTypes::ALL; |
148
|
|
|
|
149
|
|
|
return $self; |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
public function andAllIterator() : self |
153
|
|
|
{ |
154
|
|
|
$new = clone $this; |
155
|
|
|
$new->iteratorType = IteratorTypes::ALL; |
156
|
|
|
|
157
|
|
|
return $new; |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
public static function ltIterator() : self |
161
|
|
|
{ |
162
|
|
|
$self = new self(); |
163
|
|
|
$self->iteratorType = IteratorTypes::LT; |
164
|
|
|
|
165
|
|
|
return $self; |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
public function andLtIterator() : self |
169
|
|
|
{ |
170
|
|
|
$new = clone $this; |
171
|
|
|
$new->iteratorType = IteratorTypes::LT; |
172
|
|
|
|
173
|
|
|
return $new; |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
public static function leIterator() : self |
177
|
|
|
{ |
178
|
|
|
$self = new self(); |
179
|
|
|
$self->iteratorType = IteratorTypes::LE; |
180
|
|
|
|
181
|
|
|
return $self; |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
public function andLeIterator() : self |
185
|
|
|
{ |
186
|
|
|
$new = clone $this; |
187
|
|
|
$new->iteratorType = IteratorTypes::LE; |
188
|
|
|
|
189
|
|
|
return $new; |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
public static function geIterator() : self |
193
|
|
|
{ |
194
|
|
|
$self = new self(); |
195
|
|
|
$self->iteratorType = IteratorTypes::GE; |
196
|
|
|
|
197
|
|
|
return $self; |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
public function andGeIterator() : self |
201
|
|
|
{ |
202
|
|
|
$new = clone $this; |
203
|
|
|
$new->iteratorType = IteratorTypes::GE; |
204
|
|
|
|
205
|
|
|
return $new; |
206
|
|
|
} |
207
|
|
|
|
208
|
|
|
public static function gtIterator() : self |
209
|
|
|
{ |
210
|
|
|
$self = new self(); |
211
|
|
|
$self->iteratorType = IteratorTypes::GT; |
212
|
|
|
|
213
|
|
|
return $self; |
214
|
|
|
} |
215
|
|
|
|
216
|
|
|
public function andGtIterator() : self |
217
|
|
|
{ |
218
|
|
|
$new = clone $this; |
219
|
|
|
$new->iteratorType = IteratorTypes::GT; |
220
|
|
|
|
221
|
|
|
return $new; |
222
|
|
|
} |
223
|
|
|
|
224
|
|
|
public static function bitsAllSetIterator() : self |
225
|
|
|
{ |
226
|
|
|
$self = new self(); |
227
|
|
|
$self->iteratorType = IteratorTypes::BITS_ALL_SET; |
228
|
|
|
|
229
|
|
|
return $self; |
230
|
|
|
} |
231
|
|
|
|
232
|
|
|
public function andBitsAllSetIterator() : self |
233
|
|
|
{ |
234
|
|
|
$new = clone $this; |
235
|
|
|
$new->iteratorType = IteratorTypes::BITS_ALL_SET; |
236
|
|
|
|
237
|
|
|
return $new; |
238
|
|
|
} |
239
|
|
|
|
240
|
|
|
public static function bitsAnySetIterator() : self |
241
|
|
|
{ |
242
|
|
|
$self = new self(); |
243
|
|
|
$self->iteratorType = IteratorTypes::BITS_ANY_SET; |
244
|
|
|
|
245
|
|
|
return $self; |
246
|
|
|
} |
247
|
|
|
|
248
|
|
|
public function andBitsAnySetIterator() : self |
249
|
|
|
{ |
250
|
|
|
$new = clone $this; |
251
|
|
|
$new->iteratorType = IteratorTypes::BITS_ANY_SET; |
252
|
|
|
|
253
|
|
|
return $new; |
254
|
|
|
} |
255
|
|
|
|
256
|
|
|
public static function bitsAllNotSetIterator() : self |
257
|
|
|
{ |
258
|
|
|
$self = new self(); |
259
|
|
|
$self->iteratorType = IteratorTypes::BITS_ALL_NOT_SET; |
260
|
|
|
|
261
|
|
|
return $self; |
262
|
|
|
} |
263
|
|
|
|
264
|
|
|
public function andBitsAllNotSetIterator() : self |
265
|
|
|
{ |
266
|
|
|
$new = clone $this; |
267
|
|
|
$new->iteratorType = IteratorTypes::BITS_ALL_NOT_SET; |
268
|
|
|
|
269
|
|
|
return $new; |
270
|
|
|
} |
271
|
|
|
|
272
|
|
|
public static function overlapsIterator() : self |
273
|
|
|
{ |
274
|
|
|
$self = new self(); |
275
|
|
|
$self->iteratorType = IteratorTypes::OVERLAPS; |
276
|
|
|
|
277
|
|
|
return $self; |
278
|
|
|
} |
279
|
|
|
|
280
|
|
|
public function andOverlapsIterator() : self |
281
|
|
|
{ |
282
|
|
|
$new = clone $this; |
283
|
|
|
$new->iteratorType = IteratorTypes::OVERLAPS; |
284
|
|
|
|
285
|
|
|
return $new; |
286
|
|
|
} |
287
|
|
|
|
288
|
|
|
public static function neighborIterator() : self |
289
|
|
|
{ |
290
|
|
|
$self = new self(); |
291
|
|
|
$self->iteratorType = IteratorTypes::NEIGHBOR; |
292
|
|
|
|
293
|
|
|
return $self; |
294
|
|
|
} |
295
|
|
|
|
296
|
|
|
public function andNeighborIterator() : self |
297
|
|
|
{ |
298
|
|
|
$new = clone $this; |
299
|
|
|
$new->iteratorType = IteratorTypes::NEIGHBOR; |
300
|
|
|
|
301
|
|
|
return $new; |
302
|
|
|
} |
303
|
|
|
|
304
|
112 |
|
public function getIteratorType() : int |
305
|
|
|
{ |
306
|
112 |
|
return $this->iteratorType; |
307
|
|
|
} |
308
|
|
|
} |
309
|
|
|
|