Completed
Push — master ( 162ff2...83d928 )
by Peter
08:18 queued 10s
created

Spec   F

Complexity

Total Complexity 60

Size/Duplication

Total Lines 679
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 48

Importance

Changes 0
Metric Value
wmc 60
lcom 0
cbo 48
dl 0
loc 679
rs 3.521
c 0
b 0
f 0

57 Methods

Rating   Name   Duplication   Size   Complexity  
A __callStatic() 0 12 3
A andX() 0 7 1
A orX() 0 7 1
A not() 0 4 1
A join() 0 4 1
A leftJoin() 0 4 1
A innerJoin() 0 4 1
A indexBy() 0 4 1
A limit() 0 4 1
A offset() 0 4 1
A slice() 0 4 1
A orderBy() 0 4 1
A groupBy() 0 4 1
A distinct() 0 4 1
A select() 0 4 1
A addSelect() 0 4 1
A selectEntity() 0 4 1
A selectAs() 0 4 1
A selectHiddenAs() 0 4 1
A asArray() 0 4 1
A asSingleScalar() 0 4 1
A asScalar() 0 4 1
A cache() 0 4 1
A roundDateTimeParams() 0 4 1
A isNull() 0 4 1
A isNotNull() 0 4 1
A in() 0 4 1
A notIn() 0 4 1
A eq() 0 4 1
A neq() 0 4 1
A lt() 0 4 1
A lte() 0 4 1
A gt() 0 4 1
A gte() 0 4 1
A like() 0 4 1
A instanceOfX() 0 4 1
A memberOfX() 0 4 1
A countOf() 0 4 1
A having() 0 4 1
A field() 0 4 1
A value() 0 4 1
A values() 0 4 1
A likePattern() 0 4 1
A countDistinct() 0 4 1
A add() 0 4 1
A sub() 0 4 1
A mul() 0 4 1
A div() 0 4 1
A mod() 0 4 1
A bAnd() 0 4 1
A bOr() 0 4 1
A bXor() 0 4 1
A bLs() 0 4 1
A bRs() 0 4 1
A bNot() 0 4 1
A fun() 0 11 2
A alias() 0 4 1

How to fix   Complexity   

Complex Class

Complex classes like Spec often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use Spec, and based on these observations, apply Extract Interface, too.

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\CountDistinct;
25
use Happyr\DoctrineSpecification\Operand\Division;
26
use Happyr\DoctrineSpecification\Operand\Field;
27
use Happyr\DoctrineSpecification\Operand\LikePattern;
28
use Happyr\DoctrineSpecification\Operand\Modulo;
29
use Happyr\DoctrineSpecification\Operand\Multiplication;
30
use Happyr\DoctrineSpecification\Operand\Operand;
31
use Happyr\DoctrineSpecification\Operand\Subtraction;
32
use Happyr\DoctrineSpecification\Operand\PlatformFunction;
33
use Happyr\DoctrineSpecification\Operand\Value;
34
use Happyr\DoctrineSpecification\Operand\Values;
35
use Happyr\DoctrineSpecification\Query\AddSelect;
36
use Happyr\DoctrineSpecification\Query\Distinct;
37
use Happyr\DoctrineSpecification\Query\GroupBy;
38
use Happyr\DoctrineSpecification\Query\IndexBy;
39
use Happyr\DoctrineSpecification\Query\InnerJoin;
40
use Happyr\DoctrineSpecification\Query\Join;
41
use Happyr\DoctrineSpecification\Query\LeftJoin;
42
use Happyr\DoctrineSpecification\Query\Limit;
43
use Happyr\DoctrineSpecification\Query\Offset;
44
use Happyr\DoctrineSpecification\Query\OrderBy;
45
use Happyr\DoctrineSpecification\Query\QueryModifier;
46
use Happyr\DoctrineSpecification\Query\Select;
47
use Happyr\DoctrineSpecification\Query\Selection\SelectAs;
48
use Happyr\DoctrineSpecification\Query\Selection\SelectEntity;
49
use Happyr\DoctrineSpecification\Query\Selection\SelectHiddenAs;
50
use Happyr\DoctrineSpecification\Query\Slice;
51
use Happyr\DoctrineSpecification\Result\AsArray;
52
use Happyr\DoctrineSpecification\Result\AsScalar;
53
use Happyr\DoctrineSpecification\Result\AsSingleScalar;
54
use Happyr\DoctrineSpecification\Result\Cache;
55
use Happyr\DoctrineSpecification\Result\RoundDateTime;
56
use Happyr\DoctrineSpecification\Specification\CountOf;
57
use Happyr\DoctrineSpecification\Specification\Having;
58
59
/**
60
 * Factory class for the specifications.
61
 *
62
 * @method static PlatformFunction CONCAT($str1, $str2)
63
 * @method static PlatformFunction SUBSTRING($str, $start, $length = null) Return substring of given string.
64
 * @method static PlatformFunction TRIM($str) Trim the string by the given trim char, defaults to whitespaces.
65
 * @method static PlatformFunction LOWER($str) Returns the string lowercased.
66
 * @method static PlatformFunction UPPER($str) Return the upper-case of the given string.
67
 * @method static PlatformFunction IDENTITY($expression, $fieldMapping = null) Retrieve the foreign key column of association of the owning side
68
 * @method static PlatformFunction LENGTH($str) Returns the length of the given string
69
 * @method static PlatformFunction LOCATE($needle, $haystack, $offset = 0) Locate the first occurrence of the substring in the string.
70
 * @method static PlatformFunction ABS($expression)
71
 * @method static PlatformFunction SQRT($q) Return the square-root of q.
72
 * @method static PlatformFunction MOD($a, $b) Return a MOD b.
73
 * @method static PlatformFunction SIZE($collection) Return the number of elements in the specified collection
74
 * @method static PlatformFunction DATE_DIFF($date1, $date2) Calculate the difference in days between date1-date2.
75
 * @method static PlatformFunction BIT_AND($a, $b)
76
 * @method static PlatformFunction BIT_OR($a, $b)
77
 * @method static PlatformFunction MIN($a)
78
 * @method static PlatformFunction MAX($a)
79
 * @method static PlatformFunction AVG($a)
80
 * @method static PlatformFunction SUM($a)
81
 * @method static PlatformFunction COUNT($a)
82
 * @method static PlatformFunction CURRENT_DATE() Return the current date
83
 * @method static PlatformFunction CURRENT_TIME() Returns the current time
84
 * @method static PlatformFunction CURRENT_TIMESTAMP() Returns a timestamp of the current date and time.
85
 * @method static PlatformFunction DATE_ADD($date, $days, $unit) Add the number of days to a given date. (Supported units are DAY, MONTH)
86
 * @method static PlatformFunction DATE_SUB($date, $days, $unit) Substract the number of days from a given date. (Supported units are DAY, MONTH)
87
 */
88
class Spec
89
{
90
    /**
91
     * @param string $name
92
     * @param array  $arguments
93
     *
94
     * @return PlatformFunction
95
     */
96
    public static function __callStatic($name, array $arguments = [])
97
    {
98
        // allow use array in arguments of static function
99
        // Spec::DATE_DIFF([$date1, $date2]);
100
        // is equal
101
        // Spec::DATE_DIFF($date1, $date2);
102
        if (1 === count($arguments) && is_array(current($arguments))) {
103
            $arguments = current($arguments);
104
        }
105
106
        return self::fun($name, $arguments);
107
    }
108
109
    /*
110
     * Logic
111
     */
112
113
    /**
114
     * @return AndX
115
     */
116
    public static function andX()
117
    {
118
        $args = func_get_args();
119
        $reflection = new \ReflectionClass(AndX::class);
120
121
        return $reflection->newInstanceArgs($args);
122
    }
123
124
    /**
125
     * @return OrX
126
     */
127
    public static function orX()
128
    {
129
        $args = func_get_args();
130
        $reflection = new \ReflectionClass(OrX::class);
131
132
        return $reflection->newInstanceArgs($args);
133
    }
134
135
    /**
136
     * @param Filter $spec
137
     *
138
     * @return Not
139
     */
140
    public static function not(Filter $spec)
141
    {
142
        return new Not($spec);
143
    }
144
145
    /*
146
     * Query modifier
147
     */
148
149
    /**
150
     * @param string $field
151
     * @param string $newAlias
152
     * @param string $dqlAlias
153
     *
154
     * @return Join
155
     */
156
    public static function join($field, $newAlias, $dqlAlias = null)
157
    {
158
        return new Join($field, $newAlias, $dqlAlias);
159
    }
160
161
    /**
162
     * @param string $field
163
     * @param string $newAlias
164
     * @param string $dqlAlias
165
     *
166
     * @return LeftJoin
167
     */
168
    public static function leftJoin($field, $newAlias, $dqlAlias = null)
169
    {
170
        return new LeftJoin($field, $newAlias, $dqlAlias);
171
    }
172
173
    /**
174
     * @param string $field
175
     * @param string $newAlias
176
     * @param string $dqlAlias
177
     *
178
     * @return InnerJoin
179
     */
180
    public static function innerJoin($field, $newAlias, $dqlAlias = null)
181
    {
182
        return new InnerJoin($field, $newAlias, $dqlAlias);
183
    }
184
185
    /**
186
     * @param string $field
187
     * @param string $dqlAlias
188
     *
189
     * @return IndexBy
190
     */
191
    public static function indexBy($field, $dqlAlias = null)
192
    {
193
        return new IndexBy($field, $dqlAlias);
194
    }
195
196
    /**
197
     * @param int $count
198
     *
199
     * @return Limit
200
     */
201
    public static function limit($count)
202
    {
203
        return new Limit($count);
204
    }
205
206
    /**
207
     * @param int $count
208
     *
209
     * @return Offset
210
     */
211
    public static function offset($count)
212
    {
213
        return new Offset($count);
214
    }
215
216
    /**
217
     * @param int $sliceSize
218
     * @param int $sliceNumber
219
     *
220
     * @return Slice
221
     */
222
    public static function slice($sliceSize, $sliceNumber = 0)
223
    {
224
        return new Slice($sliceSize, $sliceNumber);
225
    }
226
227
    /**
228
     * @param string      $field
229
     * @param string      $order
230
     * @param string|null $dqlAlias
231
     *
232
     * @return OrderBy
233
     */
234
    public static function orderBy($field, $order = 'ASC', $dqlAlias = null)
235
    {
236
        return new OrderBy($field, $order, $dqlAlias);
237
    }
238
239
    /**
240
     * @param string $field
241
     * @param string $dqlAlias
242
     *
243
     * @return GroupBy
244
     */
245
    public static function groupBy($field, $dqlAlias = null)
246
    {
247
        return new GroupBy($field, $dqlAlias);
248
    }
249
250
    /**
251
     * @return Distinct
252
     */
253
    public static function distinct()
254
    {
255
        return new Distinct();
256
    }
257
258
    /*
259
     * Selection
260
     */
261
262
    /**
263
     * @param mixed $field
264
     *
265
     * @return Select
266
     */
267
    public static function select($field)
0 ignored issues
show
Unused Code introduced by
The parameter $field is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
268
    {
269
        return new Select(func_get_args());
270
    }
271
272
    /**
273
     * @param mixed $field
274
     *
275
     * @return AddSelect
276
     */
277
    public static function addSelect($field)
0 ignored issues
show
Unused Code introduced by
The parameter $field is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
278
    {
279
        return new AddSelect(func_get_args());
280
    }
281
282
    /**
283
     * @param string $dqlAlias
284
     *
285
     * @return SelectEntity
286
     */
287
    public static function selectEntity($dqlAlias)
288
    {
289
        return new SelectEntity($dqlAlias);
290
    }
291
292
    /**
293
     * @param Filter|Operand|string $expression
294
     * @param string                $alias
295
     *
296
     * @return SelectAs
297
     */
298
    public static function selectAs($expression, $alias)
299
    {
300
        return new SelectAs($expression, $alias);
301
    }
302
303
    /**
304
     * @param Filter|Operand|string $expression
305
     * @param string                $alias
306
     *
307
     * @return SelectHiddenAs
308
     */
309
    public static function selectHiddenAs($expression, $alias)
310
    {
311
        return new SelectHiddenAs($expression, $alias);
312
    }
313
314
    /*
315
     * Result modifier
316
     */
317
318
    /**
319
     * @return AsArray
320
     */
321
    public static function asArray()
322
    {
323
        return new AsArray();
324
    }
325
326
    /**
327
     * @return AsSingleScalar
328
     */
329
    public static function asSingleScalar()
330
    {
331
        return new AsSingleScalar();
332
    }
333
334
    /**
335
     * @return AsScalar
336
     */
337
    public static function asScalar()
338
    {
339
        return new AsScalar();
340
    }
341
342
    /**
343
     * @param int $cacheLifetime How many seconds the cached entry is valid
344
     *
345
     * @return Cache
346
     */
347
    public static function cache($cacheLifetime)
348
    {
349
        return new Cache($cacheLifetime);
350
    }
351
352
    /**
353
     * @param int $roundSeconds How may seconds to round time
354
     *
355
     * @return RoundDateTime
356
     */
357
    public static function roundDateTimeParams($roundSeconds)
358
    {
359
        return new RoundDateTime($roundSeconds);
360
    }
361
362
    /*
363
     * Filters
364
     */
365
366
    /**
367
     * @param Operand|string $field
368
     * @param string|null    $dqlAlias
369
     *
370
     * @return IsNull
371
     */
372
    public static function isNull($field, $dqlAlias = null)
373
    {
374
        return new IsNull($field, $dqlAlias);
375
    }
376
377
    /**
378
     * @param Operand|string $field
379
     * @param string|null    $dqlAlias
380
     *
381
     * @return IsNotNull
382
     */
383
    public static function isNotNull($field, $dqlAlias = null)
384
    {
385
        return new IsNotNull($field, $dqlAlias);
386
    }
387
388
    /**
389
     * Make sure the $field has a value equals to $value.
390
     *
391
     * @param string $field
392
     * @param mixed  $value
393
     * @param string $dqlAlias
394
     *
395
     * @return In
396
     */
397
    public static function in($field, $value, $dqlAlias = null)
398
    {
399
        return new In($field, $value, $dqlAlias);
400
    }
401
402
    /**
403
     * @param string $field
404
     * @param mixed  $value
405
     * @param string $dqlAlias
406
     *
407
     * @return Not
408
     */
409
    public static function notIn($field, $value, $dqlAlias = null)
410
    {
411
        return new Not(new In($field, $value, $dqlAlias));
412
    }
413
414
    /**
415
     * @param Operand|string $field
416
     * @param Operand|mixed  $value
417
     * @param string|null    $dqlAlias
418
     *
419
     * @return Comparison
420
     */
421
    public static function eq($field, $value, $dqlAlias = null)
422
    {
423
        return new Comparison(Comparison::EQ, $field, $value, $dqlAlias);
424
    }
425
426
    /**
427
     * @param Operand|string $field
428
     * @param Operand|mixed  $value
429
     * @param string|null    $dqlAlias
430
     *
431
     * @return Comparison
432
     */
433
    public static function neq($field, $value, $dqlAlias = null)
434
    {
435
        return new Comparison(Comparison::NEQ, $field, $value, $dqlAlias);
436
    }
437
438
    /**
439
     * @param Operand|string $field
440
     * @param Operand|mixed  $value
441
     * @param string|null    $dqlAlias
442
     *
443
     * @return Comparison
444
     */
445
    public static function lt($field, $value, $dqlAlias = null)
446
    {
447
        return new Comparison(Comparison::LT, $field, $value, $dqlAlias);
448
    }
449
450
    /**
451
     * @param Operand|string $field
452
     * @param Operand|mixed  $value
453
     * @param string|null    $dqlAlias
454
     *
455
     * @return Comparison
456
     */
457
    public static function lte($field, $value, $dqlAlias = null)
458
    {
459
        return new Comparison(Comparison::LTE, $field, $value, $dqlAlias);
460
    }
461
462
    /**
463
     * @param Operand|string $field
464
     * @param Operand|mixed  $value
465
     * @param string|null    $dqlAlias
466
     *
467
     * @return Comparison
468
     */
469
    public static function gt($field, $value, $dqlAlias = null)
470
    {
471
        return new Comparison(Comparison::GT, $field, $value, $dqlAlias);
472
    }
473
474
    /**
475
     * @param Operand|string $field
476
     * @param Operand|mixed  $value
477
     * @param string|null    $dqlAlias
478
     *
479
     * @return Comparison
480
     */
481
    public static function gte($field, $value, $dqlAlias = null)
482
    {
483
        return new Comparison(Comparison::GTE, $field, $value, $dqlAlias);
484
    }
485
486
    /**
487
     * @param Operand|string $field
488
     * @param string         $value
489
     * @param string         $format
490
     * @param string|null    $dqlAlias
491
     *
492
     * @return Like
493
     */
494
    public static function like($field, $value, $format = Like::CONTAINS, $dqlAlias = null)
495
    {
496
        return new Like($field, $value, $format, $dqlAlias);
497
    }
498
499
    /**
500
     * @param string      $value
501
     * @param string|null $dqlAlias
502
     *
503
     * @return InstanceOfX
504
     */
505
    public static function instanceOfX($value, $dqlAlias = null)
506
    {
507
        return new InstanceOfX($value, $dqlAlias);
508
    }
509
510
    /**
511
     * @param Operand|string $value
512
     * @param Operand|string $field
513
     * @param string|null    $dqlAlias
514
     *
515
     * @return MemberOfX
516
     */
517
    public static function memberOfX($value, $field, $dqlAlias = null)
518
    {
519
        return new MemberOfX($value, $field, $dqlAlias);
520
    }
521
522
    /*
523
     * Specifications
524
     */
525
526
    /**
527
     * @param Filter|QueryModifier $spec
528
     *
529
     * @return CountOf
530
     */
531
    public static function countOf($spec)
532
    {
533
        return new CountOf($spec);
534
    }
535
536
    /**
537
     * @param Filter $spec
538
     *
539
     * @return Having
540
     */
541
    public static function having($spec)
542
    {
543
        return new Having($spec);
0 ignored issues
show
Deprecated Code introduced by
The class Happyr\DoctrineSpecification\Specification\Having has been deprecated with message: Will be removed in 2.0. Use \Happyr\DoctrineSpecification\Query\Having instead.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
544
    }
545
546
    /*
547
     * Operands
548
     */
549
550
    /**
551
     * @param string      $fieldName
552
     * @param string|null $dqlAlias
553
     *
554
     * @return Field
555
     */
556
    public static function field($fieldName, $dqlAlias = null)
557
    {
558
        return new Field($fieldName, $dqlAlias);
559
    }
560
561
    /**
562
     * @param mixed           $value
563
     * @param int|string|null $valueType
564
     *
565
     * @return Value
566
     */
567
    public static function value($value, $valueType = null)
568
    {
569
        return new Value($value, $valueType);
570
    }
571
572
    /**
573
     * @param array           $values
574
     * @param int|string|null $valueType
575
     *
576
     * @return Values
577
     */
578
    public static function values($values, $valueType = null)
579
    {
580
        return new Values($values, $valueType);
581
    }
582
583
    /**
584
     * @param string $value
585
     * @param string $format
586
     *
587
     * @return LikePattern
588
     */
589
    public static function likePattern($value, $format = LikePattern::CONTAINS)
590
    {
591
        return new LikePattern($value, $format);
592
    }
593
594
    /**
595
     * @param Operand|string $field
596
     *
597
     * @return CountDistinct
598
     */
599
    public static function countDistinct($field)
600
    {
601
        return new CountDistinct($field);
602
    }
603
604
    /*
605
     * Arithmetic operands
606
     */
607
608
    /**
609
     * @param Operand|string $field
610
     * @param Operand|mixed  $value
611
     *
612
     * @return Addition
613
     */
614
    public static function add($field, $value)
615
    {
616
        return new Addition($field, $value);
617
    }
618
619
    /**
620
     * @param Operand|string $field
621
     * @param Operand|mixed  $value
622
     *
623
     * @return Subtraction
624
     */
625
    public static function sub($field, $value)
626
    {
627
        return new Subtraction($field, $value);
628
    }
629
630
    /**
631
     * @param Operand|string $field
632
     * @param Operand|mixed  $value
633
     *
634
     * @return Multiplication
635
     */
636
    public static function mul($field, $value)
637
    {
638
        return new Multiplication($field, $value);
639
    }
640
641
    /**
642
     * @param Operand|string $field
643
     * @param Operand|mixed  $value
644
     *
645
     * @return Division
646
     */
647
    public static function div($field, $value)
648
    {
649
        return new Division($field, $value);
650
    }
651
652
    /**
653
     * @param Operand|string $field
654
     * @param Operand|mixed  $value
655
     *
656
     * @return Modulo
657
     */
658
    public static function mod($field, $value)
659
    {
660
        return new Modulo($field, $value);
661
    }
662
663
    /*
664
     * Bitwise operands
665
     */
666
667
    /**
668
     * @param Operand|string $field
669
     * @param Operand|mixed  $value
670
     *
671
     * @return BitAnd
672
     */
673
    public static function bAnd($field, $value)
674
    {
675
        return new BitAnd($field, $value);
676
    }
677
678
    /**
679
     * @param Operand|string $field
680
     * @param Operand|mixed  $value
681
     *
682
     * @return BitOr
683
     */
684
    public static function bOr($field, $value)
685
    {
686
        return new BitOr($field, $value);
687
    }
688
689
    /**
690
     * @param Operand|string $field
691
     * @param Operand|mixed  $value
692
     *
693
     * @return BitXor
694
     */
695
    public static function bXor($field, $value)
696
    {
697
        return new BitXor($field, $value);
698
    }
699
700
    /**
701
     * @param Operand|string $field
702
     * @param Operand|mixed  $value
703
     *
704
     * @return BitLeftShift
705
     */
706
    public static function bLs($field, $value)
707
    {
708
        return new BitLeftShift($field, $value);
709
    }
710
711
    /**
712
     * @param Operand|string $field
713
     * @param Operand|mixed  $value
714
     *
715
     * @return BitRightShift
716
     */
717
    public static function bRs($field, $value)
718
    {
719
        return new BitRightShift($field, $value);
720
    }
721
722
    /**
723
     * @param Operand|string $field
724
     *
725
     * @return BitNot
726
     */
727
    public static function bNot($field)
728
    {
729
        return new BitNot($field);
730
    }
731
732
    /**
733
     * Call DQL function.
734
     *
735
     * Usage:
736
     *  Spec::fun('CURRENT_DATE')
737
     *  Spec::fun('DATE_DIFF', $date1, $date2)
738
     *  Spec::fun('DATE_DIFF', [$date1, $date2])
739
     *
740
     * @param string $functionName
741
     * @param mixed  $arguments
742
     *
743
     * @return PlatformFunction
744
     */
745
    public static function fun($functionName, $arguments = [])
746
    {
747
        if (2 === func_num_args()) {
748
            $arguments = (array) $arguments;
749
        } else {
750
            $arguments = func_get_args();
751
            $functionName = array_shift($arguments);
752
        }
753
754
        return new PlatformFunction($functionName, $arguments);
755
    }
756
757
    /**
758
     * @param string $alias
759
     *
760
     * @return Alias
761
     */
762
    public static function alias($alias)
763
    {
764
        return new Alias($alias);
765
    }
766
}
767