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