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