1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Happyr\DoctrineSpecification; |
4
|
|
|
|
5
|
|
|
use Happyr\DoctrineSpecification\Filter\Comparison; |
6
|
|
|
use Happyr\DoctrineSpecification\Filter\Filter; |
7
|
|
|
use Happyr\DoctrineSpecification\Filter\In; |
8
|
|
|
use Happyr\DoctrineSpecification\Filter\InstanceOfX; |
9
|
|
|
use Happyr\DoctrineSpecification\Filter\IsNotNull; |
10
|
|
|
use Happyr\DoctrineSpecification\Filter\IsNull; |
11
|
|
|
use Happyr\DoctrineSpecification\Filter\Like; |
12
|
|
|
use Happyr\DoctrineSpecification\Logic\AndX; |
13
|
|
|
use Happyr\DoctrineSpecification\Logic\Not; |
14
|
|
|
use Happyr\DoctrineSpecification\Logic\OrX; |
15
|
|
|
use Happyr\DoctrineSpecification\Operand\Addition; |
16
|
|
|
use Happyr\DoctrineSpecification\Operand\Alias; |
17
|
|
|
use Happyr\DoctrineSpecification\Operand\BitAnd; |
18
|
|
|
use Happyr\DoctrineSpecification\Operand\BitLeftShift; |
19
|
|
|
use Happyr\DoctrineSpecification\Operand\BitNot; |
20
|
|
|
use Happyr\DoctrineSpecification\Operand\BitOr; |
21
|
|
|
use Happyr\DoctrineSpecification\Operand\BitRightShift; |
22
|
|
|
use Happyr\DoctrineSpecification\Operand\BitXor; |
23
|
|
|
use Happyr\DoctrineSpecification\Operand\Division; |
24
|
|
|
use Happyr\DoctrineSpecification\Operand\Field; |
25
|
|
|
use Happyr\DoctrineSpecification\Operand\LikePattern; |
26
|
|
|
use Happyr\DoctrineSpecification\Operand\Modulo; |
27
|
|
|
use Happyr\DoctrineSpecification\Operand\Multiplication; |
28
|
|
|
use Happyr\DoctrineSpecification\Operand\Operand; |
29
|
|
|
use Happyr\DoctrineSpecification\Operand\Subtraction; |
30
|
|
|
use Happyr\DoctrineSpecification\Operand\PlatformFunction; |
31
|
|
|
use Happyr\DoctrineSpecification\Operand\Value; |
32
|
|
|
use Happyr\DoctrineSpecification\Operand\Values; |
33
|
|
|
use Happyr\DoctrineSpecification\Query\AddSelect; |
34
|
|
|
use Happyr\DoctrineSpecification\Query\GroupBy; |
35
|
|
|
use Happyr\DoctrineSpecification\Query\InnerJoin; |
36
|
|
|
use Happyr\DoctrineSpecification\Query\Join; |
37
|
|
|
use Happyr\DoctrineSpecification\Query\LeftJoin; |
38
|
|
|
use Happyr\DoctrineSpecification\Query\Limit; |
39
|
|
|
use Happyr\DoctrineSpecification\Query\Offset; |
40
|
|
|
use Happyr\DoctrineSpecification\Query\OrderBy; |
41
|
|
|
use Happyr\DoctrineSpecification\Query\QueryModifier; |
42
|
|
|
use Happyr\DoctrineSpecification\Query\Select; |
43
|
|
|
use Happyr\DoctrineSpecification\Query\Selection\SelectAs; |
44
|
|
|
use Happyr\DoctrineSpecification\Query\Selection\SelectEntity; |
45
|
|
|
use Happyr\DoctrineSpecification\Query\Selection\SelectHiddenAs; |
46
|
|
|
use Happyr\DoctrineSpecification\Query\Slice; |
47
|
|
|
use Happyr\DoctrineSpecification\Result\AsArray; |
48
|
|
|
use Happyr\DoctrineSpecification\Result\AsScalar; |
49
|
|
|
use Happyr\DoctrineSpecification\Result\AsSingleScalar; |
50
|
|
|
use Happyr\DoctrineSpecification\Result\Cache; |
51
|
|
|
use Happyr\DoctrineSpecification\Result\RoundDateTime; |
52
|
|
|
use Happyr\DoctrineSpecification\Specification\CountOf; |
53
|
|
|
use Happyr\DoctrineSpecification\Specification\Having; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Factory class for the specifications. |
57
|
|
|
* |
58
|
|
|
* @method static PlatformFunction CONCAT($str1, $str2) |
59
|
|
|
* @method static PlatformFunction SUBSTRING($str, $start, $length = null) Return substring of given string. |
60
|
|
|
* @method static PlatformFunction TRIM($str) Trim the string by the given trim char, defaults to whitespaces. |
61
|
|
|
* @method static PlatformFunction LOWER($str) Returns the string lowercased. |
62
|
|
|
* @method static PlatformFunction UPPER($str) Return the upper-case of the given string. |
63
|
|
|
* @method static PlatformFunction IDENTITY($expression, $fieldMapping = null) Retrieve the foreign key column of association of the owning side |
64
|
|
|
* @method static PlatformFunction LENGTH($str) Returns the length of the given string |
65
|
|
|
* @method static PlatformFunction LOCATE($needle, $haystack, $offset = 0) Locate the first occurrence of the substring in the string. |
66
|
|
|
* @method static PlatformFunction ABS($expression) |
67
|
|
|
* @method static PlatformFunction SQRT($q) Return the square-root of q. |
68
|
|
|
* @method static PlatformFunction MOD($a, $b) Return a MOD b. |
69
|
|
|
* @method static PlatformFunction SIZE($collection) Return the number of elements in the specified collection |
70
|
|
|
* @method static PlatformFunction DATE_DIFF($date1, $date2) Calculate the difference in days between date1-date2. |
71
|
|
|
* @method static PlatformFunction BIT_AND($a, $b) |
72
|
|
|
* @method static PlatformFunction BIT_OR($a, $b) |
73
|
|
|
* @method static PlatformFunction MIN($a) |
74
|
|
|
* @method static PlatformFunction MAX($a) |
75
|
|
|
* @method static PlatformFunction AVG($a) |
76
|
|
|
* @method static PlatformFunction SUM($a) |
77
|
|
|
* @method static PlatformFunction COUNT($a) |
78
|
|
|
* @method static PlatformFunction CURRENT_DATE() Return the current date |
79
|
|
|
* @method static PlatformFunction CURRENT_TIME() Returns the current time |
80
|
|
|
* @method static PlatformFunction CURRENT_TIMESTAMP() Returns a timestamp of the current date and time. |
81
|
|
|
* @method static PlatformFunction DATE_ADD($date, $days, $unit) Add the number of days to a given date. (Supported units are DAY, MONTH) |
82
|
|
|
* @method static PlatformFunction DATE_SUB($date, $days, $unit) Substract the number of days from a given date. (Supported units are DAY, MONTH) |
83
|
|
|
*/ |
84
|
|
|
class Spec |
85
|
|
|
{ |
86
|
|
|
/** |
87
|
|
|
* @param string $name |
88
|
|
|
* @param array $arguments |
89
|
|
|
* |
90
|
|
|
* @return PlatformFunction |
91
|
|
|
*/ |
92
|
|
|
public static function __callStatic($name, array $arguments = []) |
93
|
|
|
{ |
94
|
|
|
return self::fun($name, $arguments); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/* |
98
|
|
|
* Logic |
99
|
|
|
*/ |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* @return AndX |
103
|
|
|
*/ |
104
|
|
|
public static function andX() |
105
|
|
|
{ |
106
|
|
|
$args = func_get_args(); |
107
|
|
|
$reflection = new \ReflectionClass(AndX::class); |
108
|
|
|
|
109
|
|
|
return $reflection->newInstanceArgs($args); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* @return OrX |
114
|
|
|
*/ |
115
|
|
|
public static function orX() |
116
|
|
|
{ |
117
|
|
|
$args = func_get_args(); |
118
|
|
|
$reflection = new \ReflectionClass(OrX::class); |
119
|
|
|
|
120
|
|
|
return $reflection->newInstanceArgs($args); |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @param Filter $spec |
125
|
|
|
* |
126
|
|
|
* @return Not |
127
|
|
|
*/ |
128
|
|
|
public static function not(Filter $spec) |
129
|
|
|
{ |
130
|
|
|
return new Not($spec); |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/* |
134
|
|
|
* Query modifier |
135
|
|
|
*/ |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* @param string $field |
139
|
|
|
* @param string $newAlias |
140
|
|
|
* @param string $dqlAlias |
141
|
|
|
* |
142
|
|
|
* @return Join |
143
|
|
|
*/ |
144
|
|
|
public static function join($field, $newAlias, $dqlAlias = null) |
145
|
|
|
{ |
146
|
|
|
return new Join($field, $newAlias, $dqlAlias); |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* @param string $field |
151
|
|
|
* @param string $newAlias |
152
|
|
|
* @param string $dqlAlias |
153
|
|
|
* |
154
|
|
|
* @return LeftJoin |
155
|
|
|
*/ |
156
|
|
|
public static function leftJoin($field, $newAlias, $dqlAlias = null) |
157
|
|
|
{ |
158
|
|
|
return new LeftJoin($field, $newAlias, $dqlAlias); |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
/** |
162
|
|
|
* @param string $field |
163
|
|
|
* @param string $newAlias |
164
|
|
|
* @param string $dqlAlias |
165
|
|
|
* |
166
|
|
|
* @return InnerJoin |
167
|
|
|
*/ |
168
|
|
|
public static function innerJoin($field, $newAlias, $dqlAlias = null) |
169
|
|
|
{ |
170
|
|
|
return new InnerJoin($field, $newAlias, $dqlAlias); |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
/** |
174
|
|
|
* @param int $count |
175
|
|
|
* |
176
|
|
|
* @return Limit |
177
|
|
|
*/ |
178
|
|
|
public static function limit($count) |
179
|
|
|
{ |
180
|
|
|
return new Limit($count); |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
/** |
184
|
|
|
* @param int $count |
185
|
|
|
* |
186
|
|
|
* @return Offset |
187
|
|
|
*/ |
188
|
|
|
public static function offset($count) |
189
|
|
|
{ |
190
|
|
|
return new Offset($count); |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
/** |
194
|
|
|
* @param int $sliceSize |
195
|
|
|
* @param int $sliceNumber |
196
|
|
|
* |
197
|
|
|
* @return Slice |
198
|
|
|
*/ |
199
|
|
|
public static function slice($sliceSize, $sliceNumber = 0) |
200
|
|
|
{ |
201
|
|
|
return new Slice($sliceSize, $sliceNumber); |
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
/** |
205
|
|
|
* @param string $field |
206
|
|
|
* @param string $order |
207
|
|
|
* @param string|null $dqlAlias |
208
|
|
|
* |
209
|
|
|
* @return OrderBy |
210
|
|
|
*/ |
211
|
|
|
public static function orderBy($field, $order = 'ASC', $dqlAlias = null) |
212
|
|
|
{ |
213
|
|
|
return new OrderBy($field, $order, $dqlAlias); |
214
|
|
|
} |
215
|
|
|
|
216
|
|
|
/** |
217
|
|
|
* @param string $field |
218
|
|
|
* @param string $dqlAlias |
219
|
|
|
* |
220
|
|
|
* @return GroupBy |
221
|
|
|
*/ |
222
|
|
|
public static function groupBy($field, $dqlAlias = null) |
223
|
|
|
{ |
224
|
|
|
return new GroupBy($field, $dqlAlias); |
225
|
|
|
} |
226
|
|
|
|
227
|
|
|
/* |
228
|
|
|
* Selection |
229
|
|
|
*/ |
230
|
|
|
|
231
|
|
|
/** |
232
|
|
|
* @param mixed $field |
233
|
|
|
* |
234
|
|
|
* @return Select |
235
|
|
|
*/ |
236
|
|
|
public static function select($field) |
|
|
|
|
237
|
|
|
{ |
238
|
|
|
return new Select(func_get_args()); |
239
|
|
|
} |
240
|
|
|
|
241
|
|
|
/** |
242
|
|
|
* @param mixed $field |
243
|
|
|
* |
244
|
|
|
* @return AddSelect |
245
|
|
|
*/ |
246
|
|
|
public static function addSelect($field) |
|
|
|
|
247
|
|
|
{ |
248
|
|
|
return new AddSelect(func_get_args()); |
249
|
|
|
} |
250
|
|
|
|
251
|
|
|
/** |
252
|
|
|
* @param string $dqlAlias |
253
|
|
|
* |
254
|
|
|
* @return SelectEntity |
255
|
|
|
*/ |
256
|
|
|
public static function selectEntity($dqlAlias) |
257
|
|
|
{ |
258
|
|
|
return new SelectEntity($dqlAlias); |
259
|
|
|
} |
260
|
|
|
|
261
|
|
|
/** |
262
|
|
|
* @param Filter|Operand|string $expression |
263
|
|
|
* @param string $alias |
264
|
|
|
* |
265
|
|
|
* @return SelectAs |
266
|
|
|
*/ |
267
|
|
|
public static function selectAs($expression, $alias) |
268
|
|
|
{ |
269
|
|
|
return new SelectAs($expression, $alias); |
270
|
|
|
} |
271
|
|
|
|
272
|
|
|
/** |
273
|
|
|
* @param Filter|Operand|string $expression |
274
|
|
|
* @param string $alias |
275
|
|
|
* |
276
|
|
|
* @return SelectHiddenAs |
277
|
|
|
*/ |
278
|
|
|
public static function selectHiddenAs($expression, $alias) |
279
|
|
|
{ |
280
|
|
|
return new SelectHiddenAs($expression, $alias); |
281
|
|
|
} |
282
|
|
|
|
283
|
|
|
/* |
284
|
|
|
* Result modifier |
285
|
|
|
*/ |
286
|
|
|
|
287
|
|
|
/** |
288
|
|
|
* @return AsArray |
289
|
|
|
*/ |
290
|
|
|
public static function asArray() |
291
|
|
|
{ |
292
|
|
|
return new AsArray(); |
293
|
|
|
} |
294
|
|
|
|
295
|
|
|
/** |
296
|
|
|
* @return AsSingleScalar |
297
|
|
|
*/ |
298
|
|
|
public static function asSingleScalar() |
299
|
|
|
{ |
300
|
|
|
return new AsSingleScalar(); |
301
|
|
|
} |
302
|
|
|
|
303
|
|
|
/** |
304
|
|
|
* @return AsScalar |
305
|
|
|
*/ |
306
|
|
|
public static function asScalar() |
307
|
|
|
{ |
308
|
|
|
return new AsScalar(); |
309
|
|
|
} |
310
|
|
|
|
311
|
|
|
/** |
312
|
|
|
* @param int $cacheLifetime How many seconds the cached entry is valid |
313
|
|
|
* |
314
|
|
|
* @return Cache |
315
|
|
|
*/ |
316
|
|
|
public static function cache($cacheLifetime) |
317
|
|
|
{ |
318
|
|
|
return new Cache($cacheLifetime); |
319
|
|
|
} |
320
|
|
|
|
321
|
|
|
/** |
322
|
|
|
* @param int $roundSeconds How may seconds to round time |
323
|
|
|
* |
324
|
|
|
* @return RoundDateTime |
325
|
|
|
*/ |
326
|
|
|
public static function roundDateTimeParams($roundSeconds) |
327
|
|
|
{ |
328
|
|
|
return new RoundDateTime($roundSeconds); |
329
|
|
|
} |
330
|
|
|
|
331
|
|
|
/* |
332
|
|
|
* Filters |
333
|
|
|
*/ |
334
|
|
|
|
335
|
|
|
/** |
336
|
|
|
* @param Operand|string $field |
337
|
|
|
* @param string|null $dqlAlias |
338
|
|
|
* |
339
|
|
|
* @return IsNull |
340
|
|
|
*/ |
341
|
|
|
public static function isNull($field, $dqlAlias = null) |
342
|
|
|
{ |
343
|
|
|
return new IsNull($field, $dqlAlias); |
344
|
|
|
} |
345
|
|
|
|
346
|
|
|
/** |
347
|
|
|
* @param Operand|string $field |
348
|
|
|
* @param string|null $dqlAlias |
349
|
|
|
* |
350
|
|
|
* @return IsNotNull |
351
|
|
|
*/ |
352
|
|
|
public static function isNotNull($field, $dqlAlias = null) |
353
|
|
|
{ |
354
|
|
|
return new IsNotNull($field, $dqlAlias); |
355
|
|
|
} |
356
|
|
|
|
357
|
|
|
/** |
358
|
|
|
* Make sure the $field has a value equals to $value. |
359
|
|
|
* |
360
|
|
|
* @param string $field |
361
|
|
|
* @param mixed $value |
362
|
|
|
* @param string $dqlAlias |
363
|
|
|
* |
364
|
|
|
* @return In |
365
|
|
|
*/ |
366
|
|
|
public static function in($field, $value, $dqlAlias = null) |
367
|
|
|
{ |
368
|
|
|
return new In($field, $value, $dqlAlias); |
369
|
|
|
} |
370
|
|
|
|
371
|
|
|
/** |
372
|
|
|
* @param string $field |
373
|
|
|
* @param mixed $value |
374
|
|
|
* @param string $dqlAlias |
375
|
|
|
* |
376
|
|
|
* @return Not |
377
|
|
|
*/ |
378
|
|
|
public static function notIn($field, $value, $dqlAlias = null) |
379
|
|
|
{ |
380
|
|
|
return new Not(new In($field, $value, $dqlAlias)); |
381
|
|
|
} |
382
|
|
|
|
383
|
|
|
/** |
384
|
|
|
* @param Operand|string $field |
385
|
|
|
* @param Operand|mixed $value |
386
|
|
|
* @param string|null $dqlAlias |
387
|
|
|
* |
388
|
|
|
* @return Comparison |
389
|
|
|
*/ |
390
|
|
|
public static function eq($field, $value, $dqlAlias = null) |
391
|
|
|
{ |
392
|
|
|
return new Comparison(Comparison::EQ, $field, $value, $dqlAlias); |
393
|
|
|
} |
394
|
|
|
|
395
|
|
|
/** |
396
|
|
|
* @param Operand|string $field |
397
|
|
|
* @param Operand|mixed $value |
398
|
|
|
* @param string|null $dqlAlias |
399
|
|
|
* |
400
|
|
|
* @return Comparison |
401
|
|
|
*/ |
402
|
|
|
public static function neq($field, $value, $dqlAlias = null) |
403
|
|
|
{ |
404
|
|
|
return new Comparison(Comparison::NEQ, $field, $value, $dqlAlias); |
405
|
|
|
} |
406
|
|
|
|
407
|
|
|
/** |
408
|
|
|
* @param Operand|string $field |
409
|
|
|
* @param Operand|mixed $value |
410
|
|
|
* @param string|null $dqlAlias |
411
|
|
|
* |
412
|
|
|
* @return Comparison |
413
|
|
|
*/ |
414
|
|
|
public static function lt($field, $value, $dqlAlias = null) |
415
|
|
|
{ |
416
|
|
|
return new Comparison(Comparison::LT, $field, $value, $dqlAlias); |
417
|
|
|
} |
418
|
|
|
|
419
|
|
|
/** |
420
|
|
|
* @param Operand|string $field |
421
|
|
|
* @param Operand|mixed $value |
422
|
|
|
* @param string|null $dqlAlias |
423
|
|
|
* |
424
|
|
|
* @return Comparison |
425
|
|
|
*/ |
426
|
|
|
public static function lte($field, $value, $dqlAlias = null) |
427
|
|
|
{ |
428
|
|
|
return new Comparison(Comparison::LTE, $field, $value, $dqlAlias); |
429
|
|
|
} |
430
|
|
|
|
431
|
|
|
/** |
432
|
|
|
* @param Operand|string $field |
433
|
|
|
* @param Operand|mixed $value |
434
|
|
|
* @param string|null $dqlAlias |
435
|
|
|
* |
436
|
|
|
* @return Comparison |
437
|
|
|
*/ |
438
|
|
|
public static function gt($field, $value, $dqlAlias = null) |
439
|
|
|
{ |
440
|
|
|
return new Comparison(Comparison::GT, $field, $value, $dqlAlias); |
441
|
|
|
} |
442
|
|
|
|
443
|
|
|
/** |
444
|
|
|
* @param Operand|string $field |
445
|
|
|
* @param Operand|mixed $value |
446
|
|
|
* @param string|null $dqlAlias |
447
|
|
|
* |
448
|
|
|
* @return Comparison |
449
|
|
|
*/ |
450
|
|
|
public static function gte($field, $value, $dqlAlias = null) |
451
|
|
|
{ |
452
|
|
|
return new Comparison(Comparison::GTE, $field, $value, $dqlAlias); |
453
|
|
|
} |
454
|
|
|
|
455
|
|
|
/** |
456
|
|
|
* @param Operand|string $field |
457
|
|
|
* @param string $value |
458
|
|
|
* @param string $format |
459
|
|
|
* @param string|null $dqlAlias |
460
|
|
|
* |
461
|
|
|
* @return Like |
462
|
|
|
*/ |
463
|
|
|
public static function like($field, $value, $format = Like::CONTAINS, $dqlAlias = null) |
464
|
|
|
{ |
465
|
|
|
return new Like($field, $value, $format, $dqlAlias); |
466
|
|
|
} |
467
|
|
|
|
468
|
|
|
/** |
469
|
|
|
* @param string $value |
470
|
|
|
* @param string|null $dqlAlias |
471
|
|
|
* |
472
|
|
|
* @return InstanceOfX |
473
|
|
|
*/ |
474
|
|
|
public static function instanceOfX($value, $dqlAlias = null) |
475
|
|
|
{ |
476
|
|
|
return new InstanceOfX($value, $dqlAlias); |
477
|
|
|
} |
478
|
|
|
|
479
|
|
|
/* |
480
|
|
|
* Specifications |
481
|
|
|
*/ |
482
|
|
|
|
483
|
|
|
/** |
484
|
|
|
* @param Filter|QueryModifier $spec |
485
|
|
|
* |
486
|
|
|
* @return CountOf |
487
|
|
|
*/ |
488
|
|
|
public static function countOf($spec) |
489
|
|
|
{ |
490
|
|
|
return new CountOf($spec); |
491
|
|
|
} |
492
|
|
|
|
493
|
|
|
/** |
494
|
|
|
* @param Filter|string $spec |
495
|
|
|
* |
496
|
|
|
* @return Having |
497
|
|
|
*/ |
498
|
|
|
public static function having($spec) |
499
|
|
|
{ |
500
|
|
|
return new Having($spec); |
501
|
|
|
} |
502
|
|
|
|
503
|
|
|
/* |
504
|
|
|
* Operands |
505
|
|
|
*/ |
506
|
|
|
|
507
|
|
|
/** |
508
|
|
|
* @param string $fieldName |
509
|
|
|
* |
510
|
|
|
* @return Field |
511
|
|
|
*/ |
512
|
|
|
public static function field($fieldName) |
513
|
|
|
{ |
514
|
|
|
return new Field($fieldName); |
515
|
|
|
} |
516
|
|
|
|
517
|
|
|
/** |
518
|
|
|
* @param mixed $value |
519
|
|
|
* @param int|string|null $valueType |
520
|
|
|
* |
521
|
|
|
* @return Value |
522
|
|
|
*/ |
523
|
|
|
public static function value($value, $valueType = null) |
524
|
|
|
{ |
525
|
|
|
return new Value($value, $valueType); |
526
|
|
|
} |
527
|
|
|
|
528
|
|
|
/** |
529
|
|
|
* @param array $values |
530
|
|
|
* @param int|string|null $valueType |
531
|
|
|
* |
532
|
|
|
* @return Values |
533
|
|
|
*/ |
534
|
|
|
public static function values($values, $valueType = null) |
535
|
|
|
{ |
536
|
|
|
return new Values($values, $valueType); |
537
|
|
|
} |
538
|
|
|
|
539
|
|
|
/** |
540
|
|
|
* @param string $value |
541
|
|
|
* @param string $format |
542
|
|
|
* |
543
|
|
|
* @return LikePattern |
544
|
|
|
*/ |
545
|
|
|
public static function likePattern($value, $format = LikePattern::CONTAINS) |
546
|
|
|
{ |
547
|
|
|
return new LikePattern($value, $format); |
548
|
|
|
} |
549
|
|
|
|
550
|
|
|
/* |
551
|
|
|
* Arithmetic operands |
552
|
|
|
*/ |
553
|
|
|
|
554
|
|
|
/** |
555
|
|
|
* @param Operand|string $field |
556
|
|
|
* @param Operand|mixed $value |
557
|
|
|
* |
558
|
|
|
* @return Addition |
559
|
|
|
*/ |
560
|
|
|
public static function add($field, $value) |
561
|
|
|
{ |
562
|
|
|
return new Addition($field, $value); |
563
|
|
|
} |
564
|
|
|
|
565
|
|
|
/** |
566
|
|
|
* @param Operand|string $field |
567
|
|
|
* @param Operand|mixed $value |
568
|
|
|
* |
569
|
|
|
* @return Subtraction |
570
|
|
|
*/ |
571
|
|
|
public static function sub($field, $value) |
572
|
|
|
{ |
573
|
|
|
return new Subtraction($field, $value); |
574
|
|
|
} |
575
|
|
|
|
576
|
|
|
/** |
577
|
|
|
* @param Operand|string $field |
578
|
|
|
* @param Operand|mixed $value |
579
|
|
|
* |
580
|
|
|
* @return Multiplication |
581
|
|
|
*/ |
582
|
|
|
public static function mul($field, $value) |
583
|
|
|
{ |
584
|
|
|
return new Multiplication($field, $value); |
585
|
|
|
} |
586
|
|
|
|
587
|
|
|
/** |
588
|
|
|
* @param Operand|string $field |
589
|
|
|
* @param Operand|mixed $value |
590
|
|
|
* |
591
|
|
|
* @return Division |
592
|
|
|
*/ |
593
|
|
|
public static function div($field, $value) |
594
|
|
|
{ |
595
|
|
|
return new Division($field, $value); |
596
|
|
|
} |
597
|
|
|
|
598
|
|
|
/** |
599
|
|
|
* @param Operand|string $field |
600
|
|
|
* @param Operand|mixed $value |
601
|
|
|
* |
602
|
|
|
* @return Modulo |
603
|
|
|
*/ |
604
|
|
|
public static function mod($field, $value) |
605
|
|
|
{ |
606
|
|
|
return new Modulo($field, $value); |
607
|
|
|
} |
608
|
|
|
|
609
|
|
|
/* |
610
|
|
|
* Bitwise operands |
611
|
|
|
*/ |
612
|
|
|
|
613
|
|
|
/** |
614
|
|
|
* @param Operand|string $field |
615
|
|
|
* @param Operand|mixed $value |
616
|
|
|
* |
617
|
|
|
* @return BitAnd |
618
|
|
|
*/ |
619
|
|
|
public static function bAnd($field, $value) |
620
|
|
|
{ |
621
|
|
|
return new BitAnd($field, $value); |
622
|
|
|
} |
623
|
|
|
|
624
|
|
|
/** |
625
|
|
|
* @param Operand|string $field |
626
|
|
|
* @param Operand|mixed $value |
627
|
|
|
* |
628
|
|
|
* @return BitOr |
629
|
|
|
*/ |
630
|
|
|
public static function bOr($field, $value) |
631
|
|
|
{ |
632
|
|
|
return new BitOr($field, $value); |
633
|
|
|
} |
634
|
|
|
|
635
|
|
|
/** |
636
|
|
|
* @param Operand|string $field |
637
|
|
|
* @param Operand|mixed $value |
638
|
|
|
* |
639
|
|
|
* @return BitXor |
640
|
|
|
*/ |
641
|
|
|
public static function bXor($field, $value) |
642
|
|
|
{ |
643
|
|
|
return new BitXor($field, $value); |
644
|
|
|
} |
645
|
|
|
|
646
|
|
|
/** |
647
|
|
|
* @param Operand|string $field |
648
|
|
|
* @param Operand|mixed $value |
649
|
|
|
* |
650
|
|
|
* @return BitLeftShift |
651
|
|
|
*/ |
652
|
|
|
public static function bLs($field, $value) |
653
|
|
|
{ |
654
|
|
|
return new BitLeftShift($field, $value); |
655
|
|
|
} |
656
|
|
|
|
657
|
|
|
/** |
658
|
|
|
* @param Operand|string $field |
659
|
|
|
* @param Operand|mixed $value |
660
|
|
|
* |
661
|
|
|
* @return BitRightShift |
662
|
|
|
*/ |
663
|
|
|
public static function bRs($field, $value) |
664
|
|
|
{ |
665
|
|
|
return new BitRightShift($field, $value); |
666
|
|
|
} |
667
|
|
|
|
668
|
|
|
/** |
669
|
|
|
* @param Operand|string $field |
670
|
|
|
* |
671
|
|
|
* @return BitNot |
672
|
|
|
*/ |
673
|
|
|
public static function bNot($field) |
674
|
|
|
{ |
675
|
|
|
return new BitNot($field); |
676
|
|
|
} |
677
|
|
|
|
678
|
|
|
/** |
679
|
|
|
* @param string $functionName |
680
|
|
|
* @param mixed $arguments |
681
|
|
|
* |
682
|
|
|
* @return PlatformFunction |
683
|
|
|
*/ |
684
|
|
|
public static function fun($functionName, $arguments = []) |
|
|
|
|
685
|
|
|
{ |
686
|
|
|
$arguments = func_get_args(); |
687
|
|
|
|
688
|
|
|
return new PlatformFunction(array_shift($arguments), $arguments); |
689
|
|
|
} |
690
|
|
|
|
691
|
|
|
/** |
692
|
|
|
* @param string $alias |
693
|
|
|
* |
694
|
|
|
* @return Alias |
695
|
|
|
*/ |
696
|
|
|
public static function alias($alias) |
697
|
|
|
{ |
698
|
|
|
return new Alias($alias); |
699
|
|
|
} |
700
|
|
|
} |
701
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.