Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like Expr 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 Expr, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
12 | class Expr |
||
13 | { |
||
14 | /** |
||
15 | * @var DocumentManager |
||
16 | */ |
||
17 | private $dm; |
||
18 | |||
19 | /** |
||
20 | * @var ClassMetadata |
||
21 | */ |
||
22 | private $class; |
||
23 | |||
24 | /** |
||
25 | * @var array |
||
26 | */ |
||
27 | private $expr = []; |
||
28 | |||
29 | /** |
||
30 | * The current field we are operating on. |
||
31 | * |
||
32 | * @var string |
||
33 | */ |
||
34 | private $currentField; |
||
35 | |||
36 | /** |
||
37 | * @var array |
||
38 | */ |
||
39 | private $switchBranch; |
||
40 | |||
41 | /** |
||
42 | * @inheritDoc |
||
43 | */ |
||
44 | 367 | public function __construct(DocumentManager $dm, ClassMetadata $class) |
|
49 | |||
50 | /** |
||
51 | * Returns the absolute value of a number. |
||
52 | * |
||
53 | * The <number> argument can be any valid expression as long as it resolves |
||
54 | * to a number. |
||
55 | * |
||
56 | * @see https://docs.mongodb.org/manual/reference/operator/aggregation/abs/ |
||
57 | * @param mixed|self $number |
||
58 | * @return $this |
||
59 | * |
||
60 | * @since 1.3 |
||
61 | */ |
||
62 | 3 | public function abs($number) |
|
66 | |||
67 | /** |
||
68 | * Adds numbers together or adds numbers and a date. If one of the arguments |
||
69 | * is a date, $add treats the other arguments as milliseconds to add to the |
||
70 | * date. |
||
71 | * |
||
72 | * The arguments can be any valid expression as long as they resolve to |
||
73 | * either all numbers or to numbers and a date. |
||
74 | * |
||
75 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/add/ |
||
76 | * @param mixed|self $expression1 |
||
77 | * @param mixed|self $expression2 |
||
78 | * @param mixed|self $expression3,... Additional expressions |
||
|
|||
79 | * @return $this |
||
80 | */ |
||
81 | 15 | public function add($expression1, $expression2 /* , $expression3, ... */) |
|
85 | |||
86 | /** |
||
87 | * Adds one or more $and clauses to the current expression. |
||
88 | * |
||
89 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/and/ |
||
90 | * @param array|self $expression |
||
91 | * @return $this |
||
92 | */ |
||
93 | 1 | View Code Duplication | public function addAnd($expression /*, $expression2, ... */) |
103 | |||
104 | /** |
||
105 | * Adds one or more $or clause to the current expression. |
||
106 | * |
||
107 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/or/ |
||
108 | * @param array|self $expression |
||
109 | * @return $this |
||
110 | */ |
||
111 | View Code Duplication | public function addOr($expression /*, $expression2, ... */) |
|
121 | |||
122 | /** |
||
123 | * Returns an array of all unique values that results from applying an |
||
124 | * expression to each document in a group of documents that share the same |
||
125 | * group by key. Order of the elements in the output array is unspecified. |
||
126 | * |
||
127 | * AddToSet is an accumulator operation only available in the group stage. |
||
128 | * |
||
129 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/addToSet/ |
||
130 | * @param mixed|self $expression |
||
131 | * @return $this |
||
132 | */ |
||
133 | 2 | public function addToSet($expression) |
|
137 | |||
138 | /** |
||
139 | * Evaluates an array as a set and returns true if no element in the array |
||
140 | * is false. Otherwise, returns false. An empty array returns true. |
||
141 | * |
||
142 | * The expression must resolve to an array. |
||
143 | * |
||
144 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/allElementsTrue/ |
||
145 | * @param mixed|self $expression |
||
146 | * @return $this |
||
147 | */ |
||
148 | 3 | public function allElementsTrue($expression) |
|
152 | |||
153 | /** |
||
154 | * Evaluates an array as a set and returns true if any of the elements are |
||
155 | * true and false otherwise. An empty array returns false. |
||
156 | * |
||
157 | * The expression must resolve to an array. |
||
158 | * |
||
159 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/anyElementTrue/ |
||
160 | * @param array|self $expression |
||
161 | * @return $this |
||
162 | */ |
||
163 | 3 | public function anyElementTrue($expression) |
|
167 | |||
168 | /** |
||
169 | * Returns the element at the specified array index. |
||
170 | * |
||
171 | * The <array> expression can be any valid expression as long as it resolves |
||
172 | * to an array. |
||
173 | * The <idx> expression can be any valid expression as long as it resolves |
||
174 | * to an integer. |
||
175 | * |
||
176 | * @see https://docs.mongodb.org/manual/reference/operator/aggregation/arrayElemAt/ |
||
177 | * @param mixed|self $array |
||
178 | * @param mixed|self $index |
||
179 | * @return $this |
||
180 | * |
||
181 | * @since 1.3 |
||
182 | */ |
||
183 | 3 | public function arrayElemAt($array, $index) |
|
187 | |||
188 | /** |
||
189 | * Returns the average value of the numeric values that result from applying |
||
190 | * a specified expression to each document in a group of documents that |
||
191 | * share the same group by key. Ignores nun-numeric values. |
||
192 | * |
||
193 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/avg/ |
||
194 | * @param mixed|self $expression |
||
195 | * @return $this |
||
196 | */ |
||
197 | 10 | public function avg($expression) |
|
201 | |||
202 | /** |
||
203 | * Adds a case statement for a branch of the $switch operator. |
||
204 | * |
||
205 | * Requires {@link switch()} to be called first. The argument can be any |
||
206 | * valid expression that resolves to a boolean. If the result is not a |
||
207 | * boolean, it is coerced to a boolean value. |
||
208 | * |
||
209 | * @param mixed|self $expression |
||
210 | * |
||
211 | * @return $this |
||
212 | */ |
||
213 | 6 | public function case($expression) |
|
221 | |||
222 | /** |
||
223 | * Returns the smallest integer greater than or equal to the specified number. |
||
224 | * |
||
225 | * The <number> expression can be any valid expression as long as it |
||
226 | * resolves to a number. |
||
227 | * |
||
228 | * @see https://docs.mongodb.org/manual/reference/operator/aggregation/ceil/ |
||
229 | * @param mixed|self $number |
||
230 | * @return $this |
||
231 | * |
||
232 | * @since 1.3 |
||
233 | */ |
||
234 | 3 | public function ceil($number) |
|
238 | |||
239 | /** |
||
240 | * Compares two values and returns: |
||
241 | * -1 if the first value is less than the second. |
||
242 | * 1 if the first value is greater than the second. |
||
243 | * 0 if the two values are equivalent. |
||
244 | * |
||
245 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/cmp/ |
||
246 | * @param mixed|self $expression1 |
||
247 | * @param mixed|self $expression2 |
||
248 | * @return $this |
||
249 | */ |
||
250 | 3 | public function cmp($expression1, $expression2) |
|
254 | |||
255 | /** |
||
256 | * Concatenates strings and returns the concatenated string. |
||
257 | * |
||
258 | * The arguments can be any valid expression as long as they resolve to |
||
259 | * strings. If the argument resolves to a value of null or refers to a field |
||
260 | * that is missing, $concat returns null. |
||
261 | * |
||
262 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/concat/ |
||
263 | * @param mixed|self $expression1 |
||
264 | * @param mixed|self $expression2 |
||
265 | * @param mixed|self $expression3,... Additional expressions |
||
266 | * @return $this |
||
267 | */ |
||
268 | 9 | public function concat($expression1, $expression2 /* , $expression3, ... */) |
|
272 | |||
273 | /** |
||
274 | * Concatenates arrays to return the concatenated array. |
||
275 | * |
||
276 | * The <array> expressions can be any valid expression as long as they |
||
277 | * resolve to an array. |
||
278 | * |
||
279 | * @see https://docs.mongodb.org/manual/reference/operator/aggregation/concatArrays/ |
||
280 | * @param mixed|self $array1 |
||
281 | * @param mixed|self $array2 |
||
282 | * @param mixed|self $array3, ... Additional expressions |
||
283 | * @return $this |
||
284 | * |
||
285 | * @since 1.3 |
||
286 | */ |
||
287 | 6 | public function concatArrays($array1, $array2 /* , $array3, ... */) |
|
291 | |||
292 | /** |
||
293 | * Evaluates a boolean expression to return one of the two specified return |
||
294 | * expressions. |
||
295 | * |
||
296 | * The arguments can be any valid expression. |
||
297 | * |
||
298 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/cond/ |
||
299 | * @param mixed|self $if |
||
300 | * @param mixed|self $then |
||
301 | * @param mixed|self $else |
||
302 | * @return $this |
||
303 | */ |
||
304 | 10 | public function cond($if, $then, $else) |
|
308 | |||
309 | /** |
||
310 | * Converts an expression object into an array, recursing into nested items |
||
311 | * |
||
312 | * For expression objects, it calls getExpression on the expression object. |
||
313 | * For arrays, it recursively calls itself for each array item. Other values |
||
314 | * are returned directly. |
||
315 | * |
||
316 | * @param mixed|self $expression |
||
317 | * @return string|array |
||
318 | * @internal |
||
319 | */ |
||
320 | 1 | public static function convertExpression($expression) |
|
330 | |||
331 | /** |
||
332 | * Converts a date object to a string according to a user-specified format. |
||
333 | * |
||
334 | * The format string can be any string literal, containing 0 or more format |
||
335 | * specifiers. |
||
336 | * The date argument can be any expression as long as it resolves to a date. |
||
337 | * |
||
338 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/dateToString/ |
||
339 | * @param string $format |
||
340 | * @param mixed|self $expression |
||
341 | * @return $this |
||
342 | */ |
||
343 | 3 | public function dateToString($format, $expression) |
|
347 | |||
348 | /** |
||
349 | * Returns the day of the month for a date as a number between 1 and 31. |
||
350 | * |
||
351 | * The argument can be any expression as long as it resolves to a date. |
||
352 | * |
||
353 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/dayOfMonth/ |
||
354 | * @param mixed|self $expression |
||
355 | * @return $this |
||
356 | */ |
||
357 | 7 | public function dayOfMonth($expression) |
|
361 | |||
362 | /** |
||
363 | * Returns the day of the week for a date as a number between 1 (Sunday) and |
||
364 | * 7 (Saturday). |
||
365 | * |
||
366 | * The argument can be any expression as long as it resolves to a date. |
||
367 | * |
||
368 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/dayOfWeek/ |
||
369 | * @param mixed|self $expression |
||
370 | * @return $this |
||
371 | */ |
||
372 | 7 | public function dayOfWeek($expression) |
|
376 | |||
377 | /** |
||
378 | * Returns the day of the year for a date as a number between 1 and 366. |
||
379 | * |
||
380 | * The argument can be any expression as long as it resolves to a date. |
||
381 | * |
||
382 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/dayOfYear/ |
||
383 | * @param mixed|self $expression |
||
384 | * @return $this |
||
385 | */ |
||
386 | 3 | public function dayOfYear($expression) |
|
390 | |||
391 | /** |
||
392 | * Adds a default statement for the current $switch operator. |
||
393 | * |
||
394 | * Requires {@link switch()} to be called first. The argument can be any |
||
395 | * valid expression. |
||
396 | * |
||
397 | * Note: if no default is specified and no branch evaluates to true, the |
||
398 | * $switch operator throws an error. |
||
399 | * |
||
400 | * @param mixed|self $expression |
||
401 | * |
||
402 | * @return $this |
||
403 | */ |
||
404 | 4 | public function default($expression) |
|
416 | |||
417 | /** |
||
418 | * Divides one number by another and returns the result. The first argument |
||
419 | * is divided by the second argument. |
||
420 | * |
||
421 | * The arguments can be any valid expression as long as the resolve to numbers. |
||
422 | * |
||
423 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/divide/ |
||
424 | * @param mixed|self $expression1 |
||
425 | * @param mixed|self $expression2 |
||
426 | * @return $this |
||
427 | */ |
||
428 | 3 | public function divide($expression1, $expression2) |
|
432 | |||
433 | /** |
||
434 | * Compares two values and returns whether the are equivalent. |
||
435 | * |
||
436 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/eq/ |
||
437 | * @param mixed|self $expression1 |
||
438 | * @param mixed|self $expression2 |
||
439 | * @return $this |
||
440 | */ |
||
441 | 9 | public function eq($expression1, $expression2) |
|
445 | |||
446 | /** |
||
447 | * Raises Euler’s number to the specified exponent and returns the result. |
||
448 | * |
||
449 | * The <exponent> expression can be any valid expression as long as it |
||
450 | * resolves to a number. |
||
451 | * |
||
452 | * @see https://docs.mongodb.org/manual/reference/operator/aggregation/exp/ |
||
453 | * @param mixed|self $exponent |
||
454 | * @return $this |
||
455 | * |
||
456 | * @since 1.3 |
||
457 | */ |
||
458 | 3 | public function exp($exponent) |
|
462 | |||
463 | /** |
||
464 | * Returns a new expression object |
||
465 | * |
||
466 | * @return static |
||
467 | * |
||
468 | * @since 1.3 |
||
469 | */ |
||
470 | 4 | public function expr() |
|
474 | |||
475 | /** |
||
476 | * Allows any expression to be used as a field value. |
||
477 | * |
||
478 | * @see http://docs.mongodb.org/manual/meta/aggregation-quick-reference/#aggregation-expressions |
||
479 | * @param mixed|self $value |
||
480 | * @return $this |
||
481 | */ |
||
482 | 12 | public function expression($value) |
|
489 | |||
490 | /** |
||
491 | * Set the current field for building the expression. |
||
492 | * |
||
493 | * @param string $fieldName |
||
494 | * @return $this |
||
495 | */ |
||
496 | 139 | public function field($fieldName) |
|
503 | |||
504 | /** |
||
505 | * Selects a subset of the array to return based on the specified condition. |
||
506 | * |
||
507 | * Returns an array with only those elements that match the condition. The |
||
508 | * returned elements are in the original order. |
||
509 | * |
||
510 | * @see https://docs.mongodb.org/manual/reference/operator/aggregation/filter/ |
||
511 | * @param mixed|self $input |
||
512 | * @param mixed|self $as |
||
513 | * @param mixed|self $cond |
||
514 | * @return $this |
||
515 | * |
||
516 | * @since 1.3 |
||
517 | */ |
||
518 | 3 | public function filter($input, $as, $cond) |
|
522 | |||
523 | /** |
||
524 | * Returns the value that results from applying an expression to the first |
||
525 | * document in a group of documents that share the same group by key. Only |
||
526 | * meaningful when documents are in a defined order. |
||
527 | * |
||
528 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/first/ |
||
529 | * @param mixed|self $expression |
||
530 | * @return $this |
||
531 | */ |
||
532 | 2 | public function first($expression) |
|
536 | |||
537 | /** |
||
538 | * Returns the largest integer less than or equal to the specified number. |
||
539 | * |
||
540 | * The <number> expression can be any valid expression as long as it |
||
541 | * resolves to a number. |
||
542 | * |
||
543 | * @see https://docs.mongodb.org/manual/reference/operator/aggregation/floor/ |
||
544 | * @param mixed|self $number |
||
545 | * @return $this |
||
546 | * |
||
547 | * @since 1.3 |
||
548 | */ |
||
549 | 3 | public function floor($number) |
|
553 | |||
554 | /** |
||
555 | * @return array |
||
556 | */ |
||
557 | 339 | public function getExpression() |
|
561 | |||
562 | /** |
||
563 | * Compares two values and returns: |
||
564 | * true when the first value is greater than the second value. |
||
565 | * false when the first value is less than or equivalent to the second |
||
566 | * value. |
||
567 | * |
||
568 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/gt/ |
||
569 | * @param mixed|self $expression1 |
||
570 | * @param mixed|self $expression2 |
||
571 | * @return $this |
||
572 | */ |
||
573 | 3 | public function gt($expression1, $expression2) |
|
577 | |||
578 | /** |
||
579 | * Compares two values and returns: |
||
580 | * true when the first value is greater than or equivalent to the second |
||
581 | * value. |
||
582 | * false when the first value is less than the second value. |
||
583 | * |
||
584 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/gte/ |
||
585 | * @param mixed|self $expression1 |
||
586 | * @param mixed|self $expression2 |
||
587 | * @return $this |
||
588 | */ |
||
589 | 6 | public function gte($expression1, $expression2) |
|
593 | |||
594 | /** |
||
595 | * Returns the hour portion of a date as a number between 0 and 23. |
||
596 | * |
||
597 | * The argument can be any expression as long as it resolves to a date. |
||
598 | * |
||
599 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/hour/ |
||
600 | * @param mixed|self $expression |
||
601 | * @return $this |
||
602 | */ |
||
603 | 3 | public function hour($expression) |
|
607 | |||
608 | /** |
||
609 | * Evaluates an expression and returns the value of the expression if the |
||
610 | * expression evaluates to a non-null value. If the expression evaluates to |
||
611 | * a null value, including instances of undefined values or missing fields, |
||
612 | * returns the value of the replacement expression. |
||
613 | * |
||
614 | * The arguments can be any valid expression. |
||
615 | * |
||
616 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/ifNull/ |
||
617 | * @param mixed|self $expression |
||
618 | * @param mixed|self $replacementExpression |
||
619 | * @return $this |
||
620 | */ |
||
621 | 3 | public function ifNull($expression, $replacementExpression) |
|
625 | |||
626 | /** |
||
627 | * Returns a boolean indicating whether a specified value is in an array. |
||
628 | * |
||
629 | * Unlike the $in query operator, the aggregation $in operator does not |
||
630 | * support matching by regular expressions. |
||
631 | * |
||
632 | * @see https://docs.mongodb.com/manual/reference/operator/aggregation/in/ |
||
633 | * @since 1.5 |
||
634 | * @param mixed|self $expression |
||
635 | * @param mixed|self $arrayExpression |
||
636 | * @return $this |
||
637 | */ |
||
638 | 3 | public function in($expression, $arrayExpression) |
|
642 | |||
643 | /** |
||
644 | * Searches an array for an occurence of a specified value and returns the |
||
645 | * array index (zero-based) of the first occurence. If the value is not |
||
646 | * found, returns -1. |
||
647 | * |
||
648 | * @see https://docs.mongodb.com/manual/reference/operator/aggregation/indexOfArray/ |
||
649 | * @since 1.5 |
||
650 | * @param mixed|self $arrayExpression Can be any valid expression as long as it resolves to an array. |
||
651 | * @param mixed|self $searchExpression Can be any valid expression. |
||
652 | * @param mixed|self $start Optional. An integer, or a number that can be represented as integers (such as 2.0), that specifies the starting index position for the search. Can be any valid expression that resolves to a non-negative integral number. |
||
653 | * @param mixed|self $end An integer, or a number that can be represented as integers (such as 2.0), that specifies the ending index position for the search. Can be any valid expression that resolves to a non-negative integral number. |
||
654 | * @return $this |
||
655 | */ |
||
656 | 12 | View Code Duplication | public function indexOfArray($arrayExpression, $searchExpression, $start = null, $end = null) |
669 | |||
670 | /** |
||
671 | * Searches a string for an occurence of a substring and returns the UTF-8 |
||
672 | * byte index (zero-based) of the first occurence. If the substring is not |
||
673 | * found, returns -1. |
||
674 | * |
||
675 | * @see https://docs.mongodb.com/manual/reference/operator/aggregation/indexOfBytes/ |
||
676 | * @since 1.5 |
||
677 | * @param mixed|self $stringExpression Can be any valid expression as long as it resolves to a string. |
||
678 | * @param mixed|self $substringExpression Can be any valid expression as long as it resolves to a string. |
||
679 | * @param int|null $start An integral number that specifies the starting index position for the search. Can be any valid expression that resolves to a non-negative integral number. |
||
680 | * @param int|null $end An integral number that specifies the ending index position for the search. Can be any valid expression that resolves to a non-negative integral number. |
||
681 | * |
||
682 | * @return $this |
||
683 | */ |
||
684 | 12 | View Code Duplication | public function indexOfBytes($stringExpression, $substringExpression, $start = null, $end = null) |
697 | |||
698 | /** |
||
699 | * Searches a string for an occurence of a substring and returns the UTF-8 |
||
700 | * code point index (zero-based) of the first occurence. If the substring is |
||
701 | * not found, returns -1. |
||
702 | * |
||
703 | * @see https://docs.mongodb.com/manual/reference/operator/aggregation/indexOfCP/ |
||
704 | * @since 1.5 |
||
705 | * @param mixed|self $stringExpression Can be any valid expression as long as it resolves to a string. |
||
706 | * @param mixed|self $substringExpression Can be any valid expression as long as it resolves to a string. |
||
707 | * @param int|null $start An integral number that specifies the starting index position for the search. Can be any valid expression that resolves to a non-negative integral number. |
||
708 | * @param int|null $end An integral number that specifies the ending index position for the search. Can be any valid expression that resolves to a non-negative integral number. |
||
709 | * |
||
710 | * @return $this |
||
711 | */ |
||
712 | 12 | View Code Duplication | public function indexOfCP($stringExpression, $substringExpression, $start = null, $end = null) |
725 | |||
726 | /** |
||
727 | * Determines if the operand is an array. Returns a boolean. |
||
728 | * |
||
729 | * The <expression> can be any valid expression. |
||
730 | * |
||
731 | * @see https://docs.mongodb.org/manual/reference/operator/aggregation/isArray/ |
||
732 | * @param mixed|self $expression |
||
733 | * @return $this |
||
734 | * |
||
735 | * @since 1.3 |
||
736 | */ |
||
737 | 3 | public function isArray($expression) |
|
741 | |||
742 | /** |
||
743 | * Returns the weekday number in ISO 8601 format, ranging from 1 (for Monday) |
||
744 | * to 7 (for Sunday). |
||
745 | * |
||
746 | * The argument can be any expression as long as it resolves to a date. |
||
747 | * |
||
748 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/isoDayOfWeek/ |
||
749 | * @since 1.5 |
||
750 | * @param mixed|self $expression |
||
751 | * @return $this |
||
752 | */ |
||
753 | 3 | public function isoDayOfWeek($expression) |
|
757 | |||
758 | /** |
||
759 | * Returns the week number in ISO 8601 format, ranging from 1 to 53. |
||
760 | * |
||
761 | * Week numbers start at 1 with the week (Monday through Sunday) that |
||
762 | * contains the year’s first Thursday. |
||
763 | * |
||
764 | * The argument can be any expression as long as it resolves to a date. |
||
765 | * |
||
766 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/isoWeek/ |
||
767 | * @since 1.5 |
||
768 | * @param mixed|self $expression |
||
769 | * @return $this |
||
770 | */ |
||
771 | 3 | public function isoWeek($expression) |
|
775 | |||
776 | /** |
||
777 | * Returns the year number in ISO 8601 format. |
||
778 | * |
||
779 | * The year starts with the Monday of week 1 (ISO 8601) and ends with the |
||
780 | * Sunday of the last week (ISO 8601). |
||
781 | * |
||
782 | * The argument can be any expression as long as it resolves to a date. |
||
783 | * |
||
784 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/isoWeek/ |
||
785 | * @since 1.5 |
||
786 | * @param mixed|self $expression |
||
787 | * @return $this |
||
788 | */ |
||
789 | 3 | public function isoWeekYear($expression) |
|
793 | |||
794 | /** |
||
795 | * Returns the value that results from applying an expression to the last |
||
796 | * document in a group of documents that share the same group by a field. |
||
797 | * Only meaningful when documents are in a defined order. |
||
798 | * |
||
799 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/last/ |
||
800 | * @param mixed|self $expression |
||
801 | * @return $this |
||
802 | */ |
||
803 | 2 | public function last($expression) |
|
807 | |||
808 | /** |
||
809 | * Binds variables for use in the specified expression, and returns the |
||
810 | * result of the expression. |
||
811 | * |
||
812 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/let/ |
||
813 | * @param mixed|self $vars Assignment block for the variables accessible in the in expression. To assign a variable, specify a string for the variable name and assign a valid expression for the value. |
||
814 | * @param mixed|self $in The expression to evaluate. |
||
815 | * @return $this |
||
816 | */ |
||
817 | 3 | public function let($vars, $in) |
|
821 | |||
822 | /** |
||
823 | * Returns a value without parsing. Use for values that the aggregation |
||
824 | * pipeline may interpret as an expression. |
||
825 | * |
||
826 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/literal/ |
||
827 | * @param mixed|self $value |
||
828 | * @return $this |
||
829 | */ |
||
830 | 3 | public function literal($value) |
|
834 | |||
835 | /** |
||
836 | * Calculates the natural logarithm ln (i.e loge) of a number and returns |
||
837 | * the result as a double. |
||
838 | * |
||
839 | * The <number> expression can be any valid expression as long as it |
||
840 | * resolves to a non-negative number. |
||
841 | * |
||
842 | * @see https://docs.mongodb.org/manual/reference/operator/aggregation/log/ |
||
843 | * @param mixed|self $number |
||
844 | * @return $this |
||
845 | * |
||
846 | * @since 1.3 |
||
847 | */ |
||
848 | 3 | public function ln($number) |
|
852 | |||
853 | /** |
||
854 | * Calculates the log of a number in the specified base and returns the |
||
855 | * result as a double. |
||
856 | * |
||
857 | * The <number> expression can be any valid expression as long as it |
||
858 | * resolves to a non-negative number. |
||
859 | * The <base> expression can be any valid expression as long as it resolves |
||
860 | * to a positive number greater than 1. |
||
861 | * |
||
862 | * @see https://docs.mongodb.org/manual/reference/operator/aggregation/log/ |
||
863 | * @param mixed|self $number |
||
864 | * @param mixed|self $base |
||
865 | * @return $this |
||
866 | * |
||
867 | * @since 1.3 |
||
868 | */ |
||
869 | 3 | public function log($number, $base) |
|
873 | |||
874 | /** |
||
875 | * Calculates the log base 10 of a number and returns the result as a double. |
||
876 | * |
||
877 | * The <number> expression can be any valid expression as long as it |
||
878 | * resolves to a non-negative number. |
||
879 | * |
||
880 | * @see https://docs.mongodb.org/manual/reference/operator/aggregation/log10/ |
||
881 | * @param mixed|self $number |
||
882 | * @return $this |
||
883 | * |
||
884 | * @since 1.3 |
||
885 | */ |
||
886 | 3 | public function log10($number) |
|
890 | |||
891 | /** |
||
892 | * Compares two values and returns: |
||
893 | * true when the first value is less than the second value. |
||
894 | * false when the first value is greater than or equivalent to the second |
||
895 | * value. |
||
896 | * |
||
897 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/lt/ |
||
898 | * @param mixed|self $expression1 |
||
899 | * @param mixed|self $expression2 |
||
900 | * @return $this |
||
901 | */ |
||
902 | 4 | public function lt($expression1, $expression2) |
|
906 | |||
907 | /** |
||
908 | * Compares two values and returns: |
||
909 | * true when the first value is less than or equivalent to the second value. |
||
910 | * false when the first value is greater than the second value. |
||
911 | * |
||
912 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/lte/ |
||
913 | * @param mixed|self $expression1 |
||
914 | * @param mixed|self $expression2 |
||
915 | * @return $this |
||
916 | */ |
||
917 | 6 | public function lte($expression1, $expression2) |
|
921 | |||
922 | /** |
||
923 | * Applies an expression to each item in an array and returns an array with |
||
924 | * the applied results. |
||
925 | * |
||
926 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/map/ |
||
927 | * @param mixed|self $input An expression that resolves to an array. |
||
928 | * @param string $as The variable name for the items in the input array. The in expression accesses each item in the input array by this variable. |
||
929 | * @param mixed|self $in The expression to apply to each item in the input array. The expression accesses the item by its variable name. |
||
930 | * @return $this |
||
931 | */ |
||
932 | 3 | public function map($input, $as, $in) |
|
936 | |||
937 | /** |
||
938 | * Returns the highest value that results from applying an expression to |
||
939 | * each document in a group of documents that share the same group by key. |
||
940 | * |
||
941 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/max/ |
||
942 | * @param mixed|self $expression |
||
943 | * @return $this |
||
944 | */ |
||
945 | 3 | public function max($expression) |
|
949 | |||
950 | /** |
||
951 | * Returns the metadata associated with a document in a pipeline operations. |
||
952 | * |
||
953 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/meta/ |
||
954 | * @param $metaDataKeyword |
||
955 | * @return $this |
||
956 | */ |
||
957 | 3 | public function meta($metaDataKeyword) |
|
961 | |||
962 | /** |
||
963 | * Returns the millisecond portion of a date as an integer between 0 and 999. |
||
964 | * |
||
965 | * The argument can be any expression as long as it resolves to a date. |
||
966 | * |
||
967 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/millisecond/ |
||
968 | * @param mixed|self $expression |
||
969 | * @return $this |
||
970 | */ |
||
971 | 3 | public function millisecond($expression) |
|
975 | |||
976 | /** |
||
977 | * Returns the lowest value that results from applying an expression to each |
||
978 | * document in a group of documents that share the same group by key. |
||
979 | * |
||
980 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/min/ |
||
981 | * @param mixed|self $expression |
||
982 | * @return $this |
||
983 | */ |
||
984 | 3 | public function min($expression) |
|
988 | |||
989 | /** |
||
990 | * Returns the minute portion of a date as a number between 0 and 59. |
||
991 | * |
||
992 | * The argument can be any expression as long as it resolves to a date. |
||
993 | * |
||
994 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/minute/ |
||
995 | * @param mixed|self $expression |
||
996 | * @return $this |
||
997 | */ |
||
998 | 3 | public function minute($expression) |
|
1002 | |||
1003 | /** |
||
1004 | * Divides one number by another and returns the remainder. The first |
||
1005 | * argument is divided by the second argument. |
||
1006 | * |
||
1007 | * The arguments can be any valid expression as long as they resolve to numbers. |
||
1008 | * |
||
1009 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/mod/ |
||
1010 | * @param mixed|self $expression1 |
||
1011 | * @param mixed|self $expression2 |
||
1012 | * @return $this |
||
1013 | */ |
||
1014 | 3 | public function mod($expression1, $expression2) |
|
1018 | |||
1019 | /** |
||
1020 | * Returns the month of a date as a number between 1 and 12. |
||
1021 | * |
||
1022 | * The argument can be any expression as long as it resolves to a date. |
||
1023 | * |
||
1024 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/month/ |
||
1025 | * @param mixed|self $expression |
||
1026 | * @return $this |
||
1027 | */ |
||
1028 | 3 | public function month($expression) |
|
1032 | |||
1033 | /** |
||
1034 | * Multiplies numbers together and returns the result. |
||
1035 | * |
||
1036 | * The arguments can be any valid expression as long as they resolve to numbers. |
||
1037 | * |
||
1038 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/multiply/ |
||
1039 | * @param mixed|self $expression1 |
||
1040 | * @param mixed|self $expression2 |
||
1041 | * @param mixed|self $expression3,... Additional expressions |
||
1042 | * @return $this |
||
1043 | */ |
||
1044 | 13 | public function multiply($expression1, $expression2 /* , $expression3, ... */) |
|
1048 | |||
1049 | /** |
||
1050 | * Compares two values and returns: |
||
1051 | * true when the values are not equivalent. |
||
1052 | * false when the values are equivalent. |
||
1053 | * |
||
1054 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/ne/ |
||
1055 | * @param mixed|self $expression1 |
||
1056 | * @param mixed|self $expression2 |
||
1057 | * @return $this |
||
1058 | */ |
||
1059 | 4 | public function ne($expression1, $expression2) |
|
1063 | |||
1064 | /** |
||
1065 | * Evaluates a boolean and returns the opposite boolean value. |
||
1066 | * |
||
1067 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/not/ |
||
1068 | * @param mixed|self $expression |
||
1069 | * @return $this |
||
1070 | */ |
||
1071 | 3 | public function not($expression) |
|
1075 | |||
1076 | /** |
||
1077 | * Raises a number to the specified exponent and returns the result. |
||
1078 | * |
||
1079 | * The <number> expression can be any valid expression as long as it |
||
1080 | * resolves to a non-negative number. |
||
1081 | * The <exponent> expression can be any valid expression as long as it |
||
1082 | * resolves to a number. |
||
1083 | * |
||
1084 | * @see https://docs.mongodb.org/manual/reference/operator/aggregation/pow/ |
||
1085 | * @param mixed|self $number |
||
1086 | * @param mixed|self $exponent |
||
1087 | * @return $this |
||
1088 | * |
||
1089 | * @since 1.3 |
||
1090 | */ |
||
1091 | 3 | public function pow($number, $exponent) |
|
1095 | |||
1096 | /** |
||
1097 | * Returns an array of all values that result from applying an expression to |
||
1098 | * each document in a group of documents that share the same group by key. |
||
1099 | * |
||
1100 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/push/ |
||
1101 | * @param mixed|self $expression |
||
1102 | * @return $this |
||
1103 | */ |
||
1104 | 2 | public function push($expression) |
|
1108 | |||
1109 | /** |
||
1110 | * Returns an array whose elements are a generated sequence of numbers. |
||
1111 | * |
||
1112 | * $range generates the sequence from the specified starting number by successively incrementing the starting number by the specified step value up to but not including the end point. |
||
1113 | * |
||
1114 | * @see https://docs.mongodb.com/manual/reference/operator/aggregation/range/ |
||
1115 | * @since 1.5 |
||
1116 | * @param mixed|self $start An integer that specifies the start of the sequence. Can be any valid expression that resolves to an integer. |
||
1117 | * @param mixed|self $end An integer that specifies the exclusive upper limit of the sequence. Can be any valid expression that resolves to an integer. |
||
1118 | * @param mixed|self $step Optional. An integer that specifies the increment value. Can be any valid expression that resolves to a non-zero integer. Defaults to 1. |
||
1119 | * @return $this |
||
1120 | */ |
||
1121 | 6 | public function range($start, $end, $step = 1) |
|
1125 | |||
1126 | /** |
||
1127 | * Applies an expression to each element in an array and combines them into |
||
1128 | * a single value. |
||
1129 | * |
||
1130 | * @see https://docs.mongodb.com/manual/reference/operator/aggregation/reduce/ |
||
1131 | * @since 1.5 |
||
1132 | * @param mixed|self $input Can be any valid expression that resolves to an array. |
||
1133 | * @param mixed|self $initialValue The initial cumulative value set before in is applied to the first element of the input array. |
||
1134 | * @param mixed|self $in A valid expression that $reduce applies to each element in the input array in left-to-right order. Wrap the input value with $reverseArray to yield the equivalent of applying the combining expression from right-to-left. |
||
1135 | * @return $this |
||
1136 | */ |
||
1137 | 3 | public function reduce($input, $initialValue, $in) |
|
1141 | |||
1142 | /** |
||
1143 | * Accepts an array expression as an argument and returns an array with the |
||
1144 | * elements in reverse order. |
||
1145 | * |
||
1146 | * @see https://docs.mongodb.com/manual/reference/operator/aggregation/reverseArray/ |
||
1147 | * @since 1.5 |
||
1148 | * @param mixed|self $expression |
||
1149 | * @return $this |
||
1150 | */ |
||
1151 | 3 | public function reverseArray($expression) |
|
1155 | |||
1156 | /** |
||
1157 | * Returns the second portion of a date as a number between 0 and 59, but |
||
1158 | * can be 60 to account for leap seconds. |
||
1159 | * |
||
1160 | * The argument can be any expression as long as it resolves to a date. |
||
1161 | * |
||
1162 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/second/ |
||
1163 | * @param mixed|self $expression |
||
1164 | * @return $this |
||
1165 | */ |
||
1166 | 3 | public function second($expression) |
|
1170 | |||
1171 | /** |
||
1172 | * Takes two sets and returns an array containing the elements that only |
||
1173 | * exist in the first set. |
||
1174 | * |
||
1175 | * The arguments can be any valid expression as long as they each resolve to an array. |
||
1176 | * |
||
1177 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/setDifference/ |
||
1178 | * @param mixed|self $expression1 |
||
1179 | * @param mixed|self $expression2 |
||
1180 | * @return $this |
||
1181 | */ |
||
1182 | 3 | public function setDifference($expression1, $expression2) |
|
1186 | |||
1187 | /** |
||
1188 | * Compares two or more arrays and returns true if they have the same |
||
1189 | * distinct elements and false otherwise. |
||
1190 | * |
||
1191 | * The arguments can be any valid expression as long as they each resolve to an array. |
||
1192 | * |
||
1193 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/setEquals/ |
||
1194 | * @param mixed|self $expression1 |
||
1195 | * @param mixed|self $expression2 |
||
1196 | * @param mixed|self $expression3,... Additional sets |
||
1197 | * @return $this |
||
1198 | */ |
||
1199 | 6 | public function setEquals($expression1, $expression2 /* , $expression3, ... */) |
|
1203 | |||
1204 | /** |
||
1205 | * Takes two or more arrays and returns an array that contains the elements |
||
1206 | * that appear in every input array. |
||
1207 | * |
||
1208 | * The arguments can be any valid expression as long as they each resolve to an array. |
||
1209 | * |
||
1210 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/setIntersection/ |
||
1211 | * @param mixed|self $expression1 |
||
1212 | * @param mixed|self $expression2 |
||
1213 | * @param mixed|self $expression3,... Additional sets |
||
1214 | * @return $this |
||
1215 | */ |
||
1216 | 6 | public function setIntersection($expression1, $expression2 /* , $expression3, ... */) |
|
1220 | |||
1221 | /** |
||
1222 | * Takes two arrays and returns true when the first array is a subset of the |
||
1223 | * second, including when the first array equals the second array, and false otherwise. |
||
1224 | * |
||
1225 | * The arguments can be any valid expression as long as they each resolve to an array. |
||
1226 | * |
||
1227 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/setIsSubset/ |
||
1228 | * @param mixed|self $expression1 |
||
1229 | * @param mixed|self $expression2 |
||
1230 | * @return $this |
||
1231 | */ |
||
1232 | 3 | public function setIsSubset($expression1, $expression2) |
|
1236 | |||
1237 | /** |
||
1238 | * Takes two or more arrays and returns an array containing the elements |
||
1239 | * that appear in any input array. |
||
1240 | * |
||
1241 | * The arguments can be any valid expression as long as they each resolve to an array. |
||
1242 | * |
||
1243 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/setUnion/ |
||
1244 | * @param mixed|self $expression1 |
||
1245 | * @param mixed|self $expression2 |
||
1246 | * @param mixed|self $expression3,... Additional sets |
||
1247 | * @return $this |
||
1248 | */ |
||
1249 | 6 | public function setUnion($expression1, $expression2 /* , $expression3, ... */) |
|
1253 | |||
1254 | /** |
||
1255 | * Counts and returns the total the number of items in an array. |
||
1256 | * |
||
1257 | * The argument can be any expression as long as it resolves to an array. |
||
1258 | * |
||
1259 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/size/ |
||
1260 | * @param mixed|self $expression |
||
1261 | * @return $this |
||
1262 | */ |
||
1263 | 3 | public function size($expression) |
|
1267 | |||
1268 | /** |
||
1269 | * Returns a subset of an array. |
||
1270 | * |
||
1271 | * @see https://docs.mongodb.org/manual/reference/operator/aggregation/slice/ |
||
1272 | * @param mixed|self $array |
||
1273 | * @param mixed|self $n |
||
1274 | * @param mixed|self|null $position |
||
1275 | * @return $this |
||
1276 | * |
||
1277 | * @since 1.3 |
||
1278 | */ |
||
1279 | 6 | public function slice($array, $n, $position = null) |
|
1287 | |||
1288 | /** |
||
1289 | * Divides a string into an array of substrings based on a delimiter. |
||
1290 | * |
||
1291 | * $split removes the delimiter and returns the resulting substrings as |
||
1292 | * elements of an array. If the delimiter is not found in the string, $split |
||
1293 | * returns the original string as the only element of an array. |
||
1294 | * |
||
1295 | * @see https://docs.mongodb.com/manual/reference/operator/aggregation/split/ |
||
1296 | * @since 1.5 |
||
1297 | * @param mixed|self $string The string to be split. Can be any valid expression as long as it resolves to a string. |
||
1298 | * @param mixed|self $delimiter The delimiter to use when splitting the string expression. Can be any valid expression as long as it resolves to a string. |
||
1299 | * |
||
1300 | * @return $this |
||
1301 | */ |
||
1302 | 3 | public function split($string, $delimiter) |
|
1306 | |||
1307 | /** |
||
1308 | * Calculates the square root of a positive number and returns the result as |
||
1309 | * a double. |
||
1310 | * |
||
1311 | * The argument can be any valid expression as long as it resolves to a |
||
1312 | * non-negative number. |
||
1313 | * |
||
1314 | * @see https://docs.mongodb.org/manual/reference/operator/aggregation/sqrt/ |
||
1315 | * @param mixed|self $expression |
||
1316 | * @return $this |
||
1317 | */ |
||
1318 | 3 | public function sqrt($expression) |
|
1322 | |||
1323 | /** |
||
1324 | * Calculates the population standard deviation of the input values. |
||
1325 | * |
||
1326 | * The arguments can be any expression as long as it resolves to an array. |
||
1327 | * |
||
1328 | * @see https://docs.mongodb.org/manual/reference/operator/aggregation/stdDevPop/ |
||
1329 | * @param mixed|self $expression1 |
||
1330 | * @param mixed|self $expression2,... Additional samples |
||
1331 | * @return $this |
||
1332 | * |
||
1333 | * @since 1.3 |
||
1334 | */ |
||
1335 | 5 | public function stdDevPop($expression1 /* , $expression2, ... */) |
|
1341 | |||
1342 | /** |
||
1343 | * Calculates the sample standard deviation of the input values. |
||
1344 | * |
||
1345 | * The arguments can be any expression as long as it resolves to an array. |
||
1346 | * |
||
1347 | * @see https://docs.mongodb.org/manual/reference/operator/aggregation/stdDevSamp/ |
||
1348 | * @param mixed|self $expression1 |
||
1349 | * @param mixed|self $expression2,... Additional samples |
||
1350 | * @return $this |
||
1351 | * |
||
1352 | * @since 1.3 |
||
1353 | */ |
||
1354 | 5 | public function stdDevSamp($expression1 /* , $expression2, ... */) |
|
1360 | |||
1361 | /** |
||
1362 | * Performs case-insensitive comparison of two strings. Returns |
||
1363 | * 1 if first string is “greater than” the second string. |
||
1364 | * 0 if the two strings are equal. |
||
1365 | * -1 if the first string is “less than” the second string. |
||
1366 | * |
||
1367 | * The arguments can be any valid expression as long as they resolve to strings. |
||
1368 | * |
||
1369 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/strcasecmp/ |
||
1370 | * @param mixed|self $expression1 |
||
1371 | * @param mixed|self $expression2 |
||
1372 | * @return $this |
||
1373 | */ |
||
1374 | 3 | public function strcasecmp($expression1, $expression2) |
|
1378 | |||
1379 | /** |
||
1380 | * Returns the number of UTF-8 encoded bytes in the specified string. |
||
1381 | * |
||
1382 | * @see https://docs.mongodb.com/manual/reference/operator/aggregation/strLenBytes/ |
||
1383 | * @since 1.5 |
||
1384 | * @param mixed|self $string |
||
1385 | * |
||
1386 | * @return $this |
||
1387 | */ |
||
1388 | 3 | public function strLenBytes($string) |
|
1392 | |||
1393 | /** |
||
1394 | * Returns the number of UTF-8 code points in the specified string. |
||
1395 | * |
||
1396 | * @see https://docs.mongodb.com/manual/reference/operator/aggregation/strLenCP/ |
||
1397 | * @since 1.5 |
||
1398 | * @param mixed|self $string |
||
1399 | * |
||
1400 | * @return $this |
||
1401 | */ |
||
1402 | 3 | public function strLenCP($string) |
|
1406 | |||
1407 | /** |
||
1408 | * Returns a substring of a string, starting at a specified index position |
||
1409 | * and including the specified number of characters. The index is zero-based. |
||
1410 | * |
||
1411 | * The arguments can be any valid expression as long as long as the first argument resolves to a string, and the second and third arguments resolve to integers. |
||
1412 | * |
||
1413 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/substr/ |
||
1414 | * @param mixed|self $string |
||
1415 | * @param mixed|self $start |
||
1416 | * @param mixed|self $length |
||
1417 | * @return $this |
||
1418 | */ |
||
1419 | 3 | public function substr($string, $start, $length) |
|
1423 | |||
1424 | /** |
||
1425 | * Returns the substring of a string. |
||
1426 | * |
||
1427 | * The substring starts with the character at the specified UTF-8 byte index |
||
1428 | * (zero-based) in the string and continues for the number of bytes |
||
1429 | * specified. |
||
1430 | * |
||
1431 | * @see https://docs.mongodb.com/manual/reference/operator/aggregation/substrBytes/ |
||
1432 | * @since 1.5 |
||
1433 | * @param mixed|self $string The string from which the substring will be extracted. Can be any valid expression as long as it resolves to a string. |
||
1434 | * @param mixed|self $start Indicates the starting point of the substring. Can be any valid expression as long as it resolves to a non-negative integer or number that can be represented as an integer. |
||
1435 | * @param mixed|self $count Can be any valid expression as long as it resolves to a non-negative integer or number that can be represented as an integer. |
||
1436 | * |
||
1437 | * @return $this |
||
1438 | */ |
||
1439 | 3 | public function substrBytes($string, $start, $count) |
|
1443 | |||
1444 | /** |
||
1445 | * Returns the substring of a string. |
||
1446 | * |
||
1447 | * The substring starts with the character at the specified UTF-8 code point |
||
1448 | * (CP) index (zero-based) in the string for the number of code points |
||
1449 | * specified. |
||
1450 | * |
||
1451 | * @see https://docs.mongodb.com/manual/reference/operator/aggregation/substrBytes/ |
||
1452 | * @since 1.5 |
||
1453 | * @param mixed|self $string The string from which the substring will be extracted. Can be any valid expression as long as it resolves to a string. |
||
1454 | * @param mixed|self $start Indicates the starting point of the substring. Can be any valid expression as long as it resolves to a non-negative integer or number that can be represented as an integer. |
||
1455 | * @param mixed|self $count Can be any valid expression as long as it resolves to a non-negative integer or number that can be represented as an integer. |
||
1456 | * |
||
1457 | * @return $this |
||
1458 | */ |
||
1459 | 3 | public function substrCP($string, $start, $count) |
|
1463 | |||
1464 | /** |
||
1465 | * Subtracts two numbers to return the difference. The second argument is |
||
1466 | * subtracted from the first argument. |
||
1467 | * |
||
1468 | * The arguments can be any valid expression as long as they resolve to numbers and/or dates. |
||
1469 | * |
||
1470 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/subtract/ |
||
1471 | * @param mixed|self $expression1 |
||
1472 | * @param mixed|self $expression2 |
||
1473 | * @return $this |
||
1474 | */ |
||
1475 | 3 | public function subtract($expression1, $expression2) |
|
1479 | |||
1480 | /** |
||
1481 | * Calculates and returns the sum of all the numeric values that result from |
||
1482 | * applying a specified expression to each document in a group of documents |
||
1483 | * that share the same group by key. Ignores nun-numeric values. |
||
1484 | * |
||
1485 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/sum/ |
||
1486 | * @param mixed|self $expression |
||
1487 | * @return $this |
||
1488 | */ |
||
1489 | 9 | public function sum($expression) |
|
1493 | |||
1494 | /** |
||
1495 | * Converts a string to lowercase, returning the result. |
||
1496 | * |
||
1497 | * The argument can be any expression as long as it resolves to a string. |
||
1498 | * |
||
1499 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/toLower/ |
||
1500 | * @param mixed|self $expression |
||
1501 | * @return $this |
||
1502 | */ |
||
1503 | 3 | public function toLower($expression) |
|
1507 | |||
1508 | /** |
||
1509 | * Converts a string to uppercase, returning the result. |
||
1510 | * |
||
1511 | * The argument can be any expression as long as it resolves to a string. |
||
1512 | * |
||
1513 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/toUpper/ |
||
1514 | * @param mixed|self $expression |
||
1515 | * @return $this |
||
1516 | */ |
||
1517 | 3 | public function toUpper($expression) |
|
1521 | |||
1522 | /** |
||
1523 | * Truncates a number to its integer. |
||
1524 | * |
||
1525 | * The <number> expression can be any valid expression as long as it |
||
1526 | * resolves to a number. |
||
1527 | * |
||
1528 | * @see https://docs.mongodb.org/manual/reference/operator/aggregation/trunc/ |
||
1529 | * @param mixed|self $number |
||
1530 | * @return $this |
||
1531 | * |
||
1532 | * @since 1.3 |
||
1533 | */ |
||
1534 | 3 | public function trunc($number) |
|
1538 | |||
1539 | /** |
||
1540 | * Returns a string that specifies the BSON type of the argument. |
||
1541 | * |
||
1542 | * The argument can be any valid expression. |
||
1543 | * |
||
1544 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/type/ |
||
1545 | * @since 1.5 |
||
1546 | * @param mixed|self $expression |
||
1547 | * |
||
1548 | * @return $this |
||
1549 | */ |
||
1550 | 3 | public function type($expression) |
|
1554 | |||
1555 | /** |
||
1556 | * Returns the week of the year for a date as a number between 0 and 53. |
||
1557 | * |
||
1558 | * The argument can be any expression as long as it resolves to a date. |
||
1559 | * |
||
1560 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/week/ |
||
1561 | * @param mixed|self $expression |
||
1562 | * @return $this |
||
1563 | */ |
||
1564 | 3 | public function week($expression) |
|
1568 | |||
1569 | /** |
||
1570 | * Returns the year portion of a date. |
||
1571 | * |
||
1572 | * The argument can be any expression as long as it resolves to a date. |
||
1573 | * |
||
1574 | * @see http://docs.mongodb.org/manual/reference/operator/aggregation/year/ |
||
1575 | * @param mixed|self $expression |
||
1576 | * @return $this |
||
1577 | */ |
||
1578 | 4 | public function year($expression) |
|
1582 | |||
1583 | /** |
||
1584 | * Transposes an array of input arrays so that the first element of the |
||
1585 | * output array would be an array containing, the first element of the first |
||
1586 | * input array, the first element of the second input array, etc. |
||
1587 | * |
||
1588 | * @see https://docs.mongodb.com/manual/reference/operator/aggregation/zip/ |
||
1589 | * @since 1.5 |
||
1590 | * @param mixed|self $inputs An array of expressions that resolve to arrays. The elements of these input arrays combine to form the arrays of the output array. |
||
1591 | * @param bool|null $useLongestLength A boolean which specifies whether the length of the longest array determines the number of arrays in the output array. |
||
1592 | * @param mixed|self|null $defaults An array of default element values to use if the input arrays have different lengths. You must specify useLongestLength: true along with this field, or else $zip will return an error. |
||
1593 | * @return $this |
||
1594 | */ |
||
1595 | 9 | public function zip($inputs, $useLongestLength = null, $defaults = null) |
|
1607 | |||
1608 | |||
1609 | /** |
||
1610 | * @param mixed|self $expression |
||
1611 | * @return mixed |
||
1612 | */ |
||
1613 | 343 | private function ensureArray($expression) |
|
1626 | |||
1627 | /** |
||
1628 | * @return \Doctrine\ODM\MongoDB\Persisters\DocumentPersister |
||
1629 | */ |
||
1630 | 343 | private function getDocumentPersister() |
|
1634 | |||
1635 | /** |
||
1636 | * Defines an operator and value on the expression. |
||
1637 | * |
||
1638 | * If there is a current field, the operator will be set on it; otherwise, |
||
1639 | * the operator is set at the top level of the query. |
||
1640 | * |
||
1641 | * @param string $operator |
||
1642 | * @param array|self[]|self $expression |
||
1643 | * @return $this |
||
1644 | */ |
||
1645 | 341 | private function operator($operator, $expression) |
|
1655 | |||
1656 | /** |
||
1657 | * Ensure that a current field has been set. |
||
1658 | * |
||
1659 | * @param string $method |
||
1660 | * |
||
1661 | * @throws \LogicException if a current field has not been set |
||
1662 | */ |
||
1663 | 12 | private function requiresCurrentField($method = null) |
|
1669 | |||
1670 | /** |
||
1671 | * @param string $method |
||
1672 | * |
||
1673 | * @throws \BadMethodCallException if there is no current switch operator |
||
1674 | */ |
||
1675 | 8 | private function requiresSwitchStatement($method = null) |
|
1687 | |||
1688 | /** |
||
1689 | * Evaluates a series of case expressions. When it finds an expression which |
||
1690 | * evaluates to true, $switch executes a specified expression and breaks out |
||
1691 | * of the control flow. |
||
1692 | * |
||
1693 | * To add statements, use the {@link case()}, {@link then()} and |
||
1694 | * {@link default()} methods. |
||
1695 | * |
||
1696 | * @return $this |
||
1697 | */ |
||
1698 | 4 | public function switch() |
|
1704 | |||
1705 | /** |
||
1706 | * Adds a case statement for the current branch of the $switch operator. |
||
1707 | * |
||
1708 | * Requires {@link case()} to be called first. The argument can be any valid |
||
1709 | * expression. |
||
1710 | * |
||
1711 | * @param mixed|self $expression |
||
1712 | * |
||
1713 | * @return $this |
||
1714 | */ |
||
1715 | 6 | public function then($expression) |
|
1733 | |||
1734 | } |
||
1735 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.