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 Builder 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 Builder, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 34 | class Builder |
||
| 35 | { |
||
| 36 | /** |
||
| 37 | * The DocumentManager instance for this query |
||
| 38 | * |
||
| 39 | * @var DocumentManager |
||
| 40 | */ |
||
| 41 | private $dm; |
||
| 42 | |||
| 43 | /** |
||
| 44 | * The ClassMetadata instance. |
||
| 45 | * |
||
| 46 | * @var \Doctrine\ODM\MongoDB\Mapping\ClassMetadata |
||
| 47 | */ |
||
| 48 | private $class; |
||
| 49 | |||
| 50 | /** |
||
| 51 | * The current field we are operating on. |
||
| 52 | * |
||
| 53 | * @todo Change this to private once ODM requires doctrine/mongodb 1.1+ |
||
| 54 | * @var string |
||
| 55 | */ |
||
| 56 | protected $currentField; |
||
| 57 | |||
| 58 | /** |
||
| 59 | * Whether or not to hydrate the data to documents. |
||
| 60 | * |
||
| 61 | * @var boolean |
||
| 62 | */ |
||
| 63 | private $hydrate = true; |
||
| 64 | |||
| 65 | /** |
||
| 66 | * Whether or not to refresh the data for documents that are already in the identity map. |
||
| 67 | * |
||
| 68 | * @var boolean |
||
| 69 | */ |
||
| 70 | private $refresh = false; |
||
| 71 | |||
| 72 | /** |
||
| 73 | * Array of primer Closure instances. |
||
| 74 | * |
||
| 75 | * @var array |
||
| 76 | */ |
||
| 77 | private $primers = array(); |
||
| 78 | |||
| 79 | /** |
||
| 80 | * Whether or not to register documents in UnitOfWork. |
||
| 81 | * |
||
| 82 | * @var bool |
||
| 83 | */ |
||
| 84 | private $readOnly; |
||
| 85 | |||
| 86 | /** |
||
| 87 | * The Collection instance. |
||
| 88 | * |
||
| 89 | * @var Collection |
||
| 90 | */ |
||
| 91 | private $collection; |
||
| 92 | |||
| 93 | /** |
||
| 94 | * Array containing the query data. |
||
| 95 | * |
||
| 96 | * @var array |
||
| 97 | */ |
||
| 98 | private $query = ['type' => Query::TYPE_FIND]; |
||
| 99 | |||
| 100 | /** |
||
| 101 | * The Expr instance used for building this query. |
||
| 102 | * |
||
| 103 | * This object includes the query criteria and the "new object" used for |
||
| 104 | * insert and update queries. |
||
| 105 | * |
||
| 106 | * @var Expr $expr |
||
| 107 | */ |
||
| 108 | private $expr; |
||
| 109 | |||
| 110 | /** |
||
| 111 | * Construct a Builder |
||
| 112 | * |
||
| 113 | * @param DocumentManager $dm |
||
| 114 | * @param string[]|string|null $documentName (optional) an array of document names, the document name, or none |
||
| 115 | */ |
||
| 116 | 291 | public function __construct(DocumentManager $dm, $documentName = null) |
|
| 124 | |||
| 125 | 1 | public function __clone() |
|
| 129 | |||
| 130 | /** |
||
| 131 | * Add one or more $and clauses to the current query. |
||
| 132 | * |
||
| 133 | * You can create a new expression using the {@link Builder::expr()} method. |
||
| 134 | * |
||
| 135 | * @see Expr::addAnd() |
||
| 136 | * @see http://docs.mongodb.org/manual/reference/operator/and/ |
||
| 137 | * @param array|Expr $expression |
||
| 138 | * @return $this |
||
| 139 | */ |
||
| 140 | 4 | public function addAnd($expression /* , $expression2, ... */) |
|
| 145 | |||
| 146 | /** |
||
| 147 | * Append multiple values to the current array field only if they do not |
||
| 148 | * already exist in the array. |
||
| 149 | * |
||
| 150 | * If the field does not exist, it will be set to an array containing the |
||
| 151 | * unique values in the argument. If the field is not an array, the query |
||
| 152 | * will yield an error. |
||
| 153 | * |
||
| 154 | * @deprecated 1.1 Use {@link Builder::addToSet()} with {@link Expr::each()}; Will be removed in 2.0 |
||
| 155 | * @see Expr::addManyToSet() |
||
| 156 | * @see http://docs.mongodb.org/manual/reference/operator/addToSet/ |
||
| 157 | * @see http://docs.mongodb.org/manual/reference/operator/each/ |
||
| 158 | * @param array $values |
||
| 159 | * @return $this |
||
| 160 | */ |
||
| 161 | 1 | public function addManyToSet(array $values) |
|
| 166 | |||
| 167 | /** |
||
| 168 | * Add one or more $nor clauses to the current query. |
||
| 169 | * |
||
| 170 | * You can create a new expression using the {@link Builder::expr()} method. |
||
| 171 | * |
||
| 172 | * @see Expr::addNor() |
||
| 173 | * @see http://docs.mongodb.org/manual/reference/operator/nor/ |
||
| 174 | * @param array|Expr $expression |
||
| 175 | * @return $this |
||
| 176 | */ |
||
| 177 | 3 | public function addNor($expression /* , $expression2, ... */) |
|
| 182 | |||
| 183 | /** |
||
| 184 | * Add one or more $or clauses to the current query. |
||
| 185 | * |
||
| 186 | * You can create a new expression using the {@link Builder::expr()} method. |
||
| 187 | * |
||
| 188 | * @see Expr::addOr() |
||
| 189 | * @see http://docs.mongodb.org/manual/reference/operator/or/ |
||
| 190 | * @param array|Expr $expression |
||
| 191 | * @return $this |
||
| 192 | */ |
||
| 193 | 6 | public function addOr($expression /* , $expression2, ... */) |
|
| 198 | |||
| 199 | /** |
||
| 200 | * Append one or more values to the current array field only if they do not |
||
| 201 | * already exist in the array. |
||
| 202 | * |
||
| 203 | * If the field does not exist, it will be set to an array containing the |
||
| 204 | * unique value(s) in the argument. If the field is not an array, the query |
||
| 205 | * will yield an error. |
||
| 206 | * |
||
| 207 | * Multiple values may be specified by provided an Expr object and using |
||
| 208 | * {@link Expr::each()}. |
||
| 209 | * |
||
| 210 | * @see Expr::addToSet() |
||
| 211 | * @see http://docs.mongodb.org/manual/reference/operator/addToSet/ |
||
| 212 | * @see http://docs.mongodb.org/manual/reference/operator/each/ |
||
| 213 | * @param mixed|Expr $valueOrExpression |
||
| 214 | * @return $this |
||
| 215 | */ |
||
| 216 | 5 | public function addToSet($valueOrExpression) |
|
| 221 | |||
| 222 | /** |
||
| 223 | * Specify $all criteria for the current field. |
||
| 224 | * |
||
| 225 | * @see Expr::all() |
||
| 226 | * @see http://docs.mongodb.org/manual/reference/operator/all/ |
||
| 227 | * @param array $values |
||
| 228 | * @return $this |
||
| 229 | */ |
||
| 230 | 3 | public function all(array $values) |
|
| 235 | |||
| 236 | /** |
||
| 237 | * Apply a bitwise and operation on the current field. |
||
| 238 | * |
||
| 239 | * @see Expr::bitAnd() |
||
| 240 | * @see http://docs.mongodb.org/manual/reference/operator/update/bit/ |
||
| 241 | * @param int $value |
||
| 242 | * @return $this |
||
| 243 | */ |
||
| 244 | 1 | public function bitAnd($value) |
|
| 249 | |||
| 250 | /** |
||
| 251 | * Apply a bitwise or operation on the current field. |
||
| 252 | * |
||
| 253 | * @see Expr::bitOr() |
||
| 254 | * @see http://docs.mongodb.org/manual/reference/operator/update/bit/ |
||
| 255 | * @param int $value |
||
| 256 | * @return $this |
||
| 257 | */ |
||
| 258 | 1 | public function bitOr($value) |
|
| 263 | |||
| 264 | /** |
||
| 265 | * Matches documents where all of the bit positions given by the query are |
||
| 266 | * clear. |
||
| 267 | * |
||
| 268 | * @see Expr::bitsAllClear() |
||
| 269 | * @see https://docs.mongodb.org/manual/reference/operator/query/bitsAllClear/ |
||
| 270 | * @param int|array|\MongoBinData $value |
||
| 271 | * @return $this |
||
| 272 | */ |
||
| 273 | 1 | public function bitsAllClear($value) |
|
| 278 | |||
| 279 | /** |
||
| 280 | * Matches documents where all of the bit positions given by the query are |
||
| 281 | * set. |
||
| 282 | * |
||
| 283 | * @see Expr::bitsAllSet() |
||
| 284 | * @see https://docs.mongodb.org/manual/reference/operator/query/bitsAllSet/ |
||
| 285 | * @param int|array|\MongoBinData $value |
||
| 286 | * @return $this |
||
| 287 | */ |
||
| 288 | 1 | public function bitsAllSet($value) |
|
| 293 | |||
| 294 | /** |
||
| 295 | * Matches documents where any of the bit positions given by the query are |
||
| 296 | * clear. |
||
| 297 | * |
||
| 298 | * @see Expr::bitsAnyClear() |
||
| 299 | * @see https://docs.mongodb.org/manual/reference/operator/query/bitsAnyClear/ |
||
| 300 | * @param int|array|\MongoBinData $value |
||
| 301 | * @return $this |
||
| 302 | */ |
||
| 303 | 1 | public function bitsAnyClear($value) |
|
| 308 | |||
| 309 | /** |
||
| 310 | * Matches documents where any of the bit positions given by the query are |
||
| 311 | * set. |
||
| 312 | * |
||
| 313 | * @see Expr::bitsAnySet() |
||
| 314 | * @see https://docs.mongodb.org/manual/reference/operator/query/bitsAnySet/ |
||
| 315 | * @param int|array|\MongoBinData $value |
||
| 316 | * @return $this |
||
| 317 | */ |
||
| 318 | 1 | public function bitsAnySet($value) |
|
| 323 | |||
| 324 | /** |
||
| 325 | * Apply a bitwise xor operation on the current field. |
||
| 326 | * |
||
| 327 | * @see Expr::bitXor() |
||
| 328 | * @see http://docs.mongodb.org/manual/reference/operator/update/bit/ |
||
| 329 | * @param int $value |
||
| 330 | * @return $this |
||
| 331 | */ |
||
| 332 | 1 | public function bitXor($value) |
|
| 337 | |||
| 338 | /** |
||
| 339 | * A boolean flag to enable or disable case sensitive search for $text |
||
| 340 | * criteria. |
||
| 341 | * |
||
| 342 | * This method must be called after text(). |
||
| 343 | * |
||
| 344 | * @see Expr::caseSensitive() |
||
| 345 | * @see http://docs.mongodb.org/manual/reference/operator/text/ |
||
| 346 | * @param bool $caseSensitive |
||
| 347 | * @return $this |
||
| 348 | * @throws \BadMethodCallException if the query does not already have $text criteria |
||
| 349 | * |
||
| 350 | * @since 1.3 |
||
| 351 | */ |
||
| 352 | 1 | public function caseSensitive($caseSensitive) |
|
| 357 | |||
| 358 | /** |
||
| 359 | * Associates a comment to any expression taking a query predicate. |
||
| 360 | * |
||
| 361 | * @see Expr::comment() |
||
| 362 | * @see http://docs.mongodb.org/manual/reference/operator/query/comment/ |
||
| 363 | * @param string $comment |
||
| 364 | * @return $this |
||
| 365 | */ |
||
| 366 | 1 | public function comment($comment) |
|
| 371 | |||
| 372 | /** |
||
| 373 | * Change the query type to count. |
||
| 374 | * |
||
| 375 | * @return $this |
||
| 376 | */ |
||
| 377 | public function count() |
||
| 382 | |||
| 383 | /** |
||
| 384 | * Sets the value of the current field to the current date, either as a date or a timestamp. |
||
| 385 | * |
||
| 386 | * @see Expr::currentDate() |
||
| 387 | * @see http://docs.mongodb.org/manual/reference/operator/currentDate/ |
||
| 388 | * @param string $type |
||
| 389 | * @return $this |
||
| 390 | */ |
||
| 391 | 3 | public function currentDate($type = 'date') |
|
| 396 | |||
| 397 | /** |
||
| 398 | * Return an array of information about the Builder state for debugging. |
||
| 399 | * |
||
| 400 | * The $name parameter may be used to return a specific key from the |
||
| 401 | * internal $query array property. If omitted, the entire array will be |
||
| 402 | * returned. |
||
| 403 | * |
||
| 404 | * @param string $name |
||
| 405 | * @return mixed |
||
| 406 | */ |
||
| 407 | 28 | public function debug($name = null) |
|
| 411 | |||
| 412 | /** |
||
| 413 | * A boolean flag to enable or disable diacritic sensitive search for $text |
||
| 414 | * criteria. |
||
| 415 | * |
||
| 416 | * This method must be called after text(). |
||
| 417 | * |
||
| 418 | * @see Builder::diacriticSensitive() |
||
| 419 | * @see http://docs.mongodb.org/manual/reference/operator/text/ |
||
| 420 | * @param bool $diacriticSensitive |
||
| 421 | * @return $this |
||
| 422 | * @throws \BadMethodCallException if the query does not already have $text criteria |
||
| 423 | * |
||
| 424 | * @since 1.3 |
||
| 425 | */ |
||
| 426 | 1 | public function diacriticSensitive($diacriticSensitive) |
|
| 431 | |||
| 432 | /** |
||
| 433 | * Change the query type to a distinct command. |
||
| 434 | * |
||
| 435 | * @see http://docs.mongodb.org/manual/reference/command/distinct/ |
||
| 436 | * @param string $field |
||
| 437 | * @return $this |
||
| 438 | */ |
||
| 439 | 2 | public function distinct($field) |
|
| 445 | |||
| 446 | /** |
||
| 447 | * Set whether the query should return its result as an EagerCursor. |
||
| 448 | * |
||
| 449 | * @param boolean $bool |
||
| 450 | * @return $this |
||
| 451 | */ |
||
| 452 | 5 | public function eagerCursor($bool = true) |
|
| 461 | |||
| 462 | /** |
||
| 463 | * Specify $elemMatch criteria for the current field. |
||
| 464 | * |
||
| 465 | * You can create a new expression using the {@link Builder::expr()} method. |
||
| 466 | * |
||
| 467 | * @see Expr::elemMatch() |
||
| 468 | * @see http://docs.mongodb.org/manual/reference/operator/elemMatch/ |
||
| 469 | * @param array|Expr $expression |
||
| 470 | * @return $this |
||
| 471 | */ |
||
| 472 | 6 | public function elemMatch($expression) |
|
| 477 | |||
| 478 | /** |
||
| 479 | * Specify an equality match for the current field. |
||
| 480 | * |
||
| 481 | * @see Expr::equals() |
||
| 482 | * @param mixed $value |
||
| 483 | * @return $this |
||
| 484 | */ |
||
| 485 | 75 | public function equals($value) |
|
| 490 | |||
| 491 | /** |
||
| 492 | * Set one or more fields to be excluded from the query projection. |
||
| 493 | * |
||
| 494 | * If fields have been selected for inclusion, only the "_id" field may be |
||
| 495 | * excluded. |
||
| 496 | * |
||
| 497 | * @param array|string $fieldName,... |
||
| 498 | * @return $this |
||
| 499 | */ |
||
| 500 | 6 | View Code Duplication | public function exclude($fieldName = null) |
| 514 | |||
| 515 | /** |
||
| 516 | * Specify $exists criteria for the current field. |
||
| 517 | * |
||
| 518 | * @see Expr::exists() |
||
| 519 | * @see http://docs.mongodb.org/manual/reference/operator/exists/ |
||
| 520 | * @param boolean $bool |
||
| 521 | * @return $this |
||
| 522 | */ |
||
| 523 | 5 | public function exists($bool) |
|
| 528 | |||
| 529 | /** |
||
| 530 | * Create a new Expr instance that can be used as an expression with the Builder |
||
| 531 | * |
||
| 532 | * @return Expr $expr |
||
| 533 | */ |
||
| 534 | 26 | public function expr() |
|
| 541 | |||
| 542 | /** |
||
| 543 | * Set the current field to operate on. |
||
| 544 | * |
||
| 545 | * @param string $field |
||
| 546 | * @return $this |
||
| 547 | */ |
||
| 548 | 144 | public function field($field) |
|
| 555 | |||
| 556 | /** |
||
| 557 | * Set the "finalize" option for a mapReduce or group command. |
||
| 558 | * |
||
| 559 | * @param string|\MongoCode $finalize |
||
| 560 | * @return $this |
||
| 561 | * @throws \BadMethodCallException if the query is not a mapReduce or group command |
||
| 562 | */ |
||
| 563 | 2 | View Code Duplication | public function finalize($finalize) |
| 580 | |||
| 581 | /** |
||
| 582 | * Change the query type to find and optionally set and change the class being queried. |
||
| 583 | * |
||
| 584 | * @param string $documentName |
||
| 585 | * @return $this |
||
| 586 | */ |
||
| 587 | 12 | public function find($documentName = null) |
|
| 594 | |||
| 595 | /** |
||
| 596 | * @param string $documentName |
||
| 597 | * @return $this |
||
| 598 | */ |
||
| 599 | 1 | public function findAndRemove($documentName = null) |
|
| 606 | |||
| 607 | /** |
||
| 608 | * @param string $documentName |
||
| 609 | * @return $this |
||
| 610 | */ |
||
| 611 | 13 | public function findAndUpdate($documentName = null) |
|
| 618 | |||
| 619 | /** |
||
| 620 | * Add $geoIntersects criteria with a GeoJSON geometry to the query. |
||
| 621 | * |
||
| 622 | * The geometry parameter GeoJSON object or an array corresponding to the |
||
| 623 | * geometry's JSON representation. |
||
| 624 | * |
||
| 625 | * @see Expr::geoIntersects() |
||
| 626 | * @see http://docs.mongodb.org/manual/reference/operator/geoIntersects/ |
||
| 627 | * @param array|Geometry $geometry |
||
| 628 | * @return $this |
||
| 629 | */ |
||
| 630 | 1 | public function geoIntersects($geometry) |
|
| 635 | |||
| 636 | /** |
||
| 637 | * Add $geoWithin criteria with a GeoJSON geometry to the query. |
||
| 638 | * |
||
| 639 | * The geometry parameter GeoJSON object or an array corresponding to the |
||
| 640 | * geometry's JSON representation. |
||
| 641 | * |
||
| 642 | * @see Expr::geoWithin() |
||
| 643 | * @see http://docs.mongodb.org/manual/reference/operator/geoWithin/ |
||
| 644 | * @param array|Geometry $geometry |
||
| 645 | * @return $this |
||
| 646 | */ |
||
| 647 | 1 | public function geoWithin($geometry) |
|
| 652 | |||
| 653 | /** |
||
| 654 | * Add $geoWithin criteria with a $box shape to the query. |
||
| 655 | * |
||
| 656 | * A rectangular polygon will be constructed from a pair of coordinates |
||
| 657 | * corresponding to the bottom left and top right corners. |
||
| 658 | * |
||
| 659 | * Note: the $box operator only supports legacy coordinate pairs and 2d |
||
| 660 | * indexes. This cannot be used with 2dsphere indexes and GeoJSON shapes. |
||
| 661 | * |
||
| 662 | * @see Expr::geoWithinBox() |
||
| 663 | * @see http://docs.mongodb.org/manual/reference/operator/box/ |
||
| 664 | * @param float $x1 |
||
| 665 | * @param float $y1 |
||
| 666 | * @param float $x2 |
||
| 667 | * @param float $y2 |
||
| 668 | * @return $this |
||
| 669 | */ |
||
| 670 | 1 | public function geoWithinBox($x1, $y1, $x2, $y2) |
|
| 675 | |||
| 676 | /** |
||
| 677 | * Add $geoWithin criteria with a $center shape to the query. |
||
| 678 | * |
||
| 679 | * Note: the $center operator only supports legacy coordinate pairs and 2d |
||
| 680 | * indexes. This cannot be used with 2dsphere indexes and GeoJSON shapes. |
||
| 681 | * |
||
| 682 | * @see Expr::geoWithinCenter() |
||
| 683 | * @see http://docs.mongodb.org/manual/reference/operator/center/ |
||
| 684 | * @param float $x |
||
| 685 | * @param float $y |
||
| 686 | * @param float $radius |
||
| 687 | * @return $this |
||
| 688 | */ |
||
| 689 | 1 | public function geoWithinCenter($x, $y, $radius) |
|
| 694 | |||
| 695 | /** |
||
| 696 | * Add $geoWithin criteria with a $centerSphere shape to the query. |
||
| 697 | * |
||
| 698 | * Note: the $centerSphere operator supports both 2d and 2dsphere indexes. |
||
| 699 | * |
||
| 700 | * @see Expr::geoWithinCenterSphere() |
||
| 701 | * @see http://docs.mongodb.org/manual/reference/operator/centerSphere/ |
||
| 702 | * @param float $x |
||
| 703 | * @param float $y |
||
| 704 | * @param float $radius |
||
| 705 | * @return $this |
||
| 706 | */ |
||
| 707 | 1 | public function geoWithinCenterSphere($x, $y, $radius) |
|
| 712 | |||
| 713 | /** |
||
| 714 | * Add $geoWithin criteria with a $polygon shape to the query. |
||
| 715 | * |
||
| 716 | * Point coordinates are in x, y order (easting, northing for projected |
||
| 717 | * coordinates, longitude, latitude for geographic coordinates). |
||
| 718 | * |
||
| 719 | * The last point coordinate is implicitly connected with the first. |
||
| 720 | * |
||
| 721 | * Note: the $polygon operator only supports legacy coordinate pairs and 2d |
||
| 722 | * indexes. This cannot be used with 2dsphere indexes and GeoJSON shapes. |
||
| 723 | * |
||
| 724 | * @see Expr::geoWithinPolygon() |
||
| 725 | * @see http://docs.mongodb.org/manual/reference/operator/polygon/ |
||
| 726 | * @param array $point,... Three or more point coordinate tuples |
||
| 727 | * @return $this |
||
| 728 | */ |
||
| 729 | 1 | public function geoWithinPolygon(/* array($x1, $y1), ... */) |
|
| 734 | |||
| 735 | /** |
||
| 736 | * Return the expression's "new object". |
||
| 737 | * |
||
| 738 | * @see Expr::getNewObj() |
||
| 739 | * @return array |
||
| 740 | */ |
||
| 741 | 13 | public function getNewObj() |
|
| 745 | |||
| 746 | /** |
||
| 747 | * Gets the Query executable. |
||
| 748 | * |
||
| 749 | * @param array $options |
||
| 750 | * @return Query $query |
||
| 751 | */ |
||
| 752 | 150 | public function getQuery(array $options = array()) |
|
| 813 | |||
| 814 | /** |
||
| 815 | * Return the expression's query criteria. |
||
| 816 | * |
||
| 817 | * @see Expr::getQuery() |
||
| 818 | * @return array |
||
| 819 | */ |
||
| 820 | 33 | public function getQueryArray() |
|
| 824 | |||
| 825 | /** |
||
| 826 | * Get the type of this query. |
||
| 827 | * |
||
| 828 | * @return integer $type |
||
| 829 | */ |
||
| 830 | 2 | public function getType() |
|
| 834 | |||
| 835 | /** |
||
| 836 | * Specify $gt criteria for the current field. |
||
| 837 | * |
||
| 838 | * @see Expr::gt() |
||
| 839 | * @see http://docs.mongodb.org/manual/reference/operator/gt/ |
||
| 840 | * @param mixed $value |
||
| 841 | * @return $this |
||
| 842 | */ |
||
| 843 | 2 | public function gt($value) |
|
| 848 | |||
| 849 | /** |
||
| 850 | * Specify $gte criteria for the current field. |
||
| 851 | * |
||
| 852 | * @see Expr::gte() |
||
| 853 | * @see http://docs.mongodb.org/manual/reference/operator/gte/ |
||
| 854 | * @param mixed $value |
||
| 855 | * @return $this |
||
| 856 | */ |
||
| 857 | 2 | public function gte($value) |
|
| 862 | |||
| 863 | /** |
||
| 864 | * Set the index hint for the query. |
||
| 865 | * |
||
| 866 | * @param array|string $index |
||
| 867 | * @return $this |
||
| 868 | */ |
||
| 869 | public function hint($index) |
||
| 874 | |||
| 875 | /** |
||
| 876 | * @param bool $bool |
||
| 877 | * @return $this |
||
| 878 | */ |
||
| 879 | 17 | public function hydrate($bool = true) |
|
| 884 | |||
| 885 | /** |
||
| 886 | * Set the immortal cursor flag. |
||
| 887 | * |
||
| 888 | * @param boolean $bool |
||
| 889 | * @return $this |
||
| 890 | */ |
||
| 891 | public function immortal($bool = true) |
||
| 896 | |||
| 897 | /** |
||
| 898 | * Specify $in criteria for the current field. |
||
| 899 | * |
||
| 900 | * @see Expr::in() |
||
| 901 | * @see http://docs.mongodb.org/manual/reference/operator/in/ |
||
| 902 | * @param array $values |
||
| 903 | * @return $this |
||
| 904 | */ |
||
| 905 | 24 | public function in(array $values) |
|
| 910 | |||
| 911 | /** |
||
| 912 | * Increment the current field. |
||
| 913 | * |
||
| 914 | * If the field does not exist, it will be set to this value. |
||
| 915 | * |
||
| 916 | * @see Expr::inc() |
||
| 917 | * @see http://docs.mongodb.org/manual/reference/operator/inc/ |
||
| 918 | * @param float|integer $value |
||
| 919 | * @return $this |
||
| 920 | */ |
||
| 921 | 6 | public function inc($value) |
|
| 926 | |||
| 927 | /** |
||
| 928 | * @param object $document |
||
| 929 | * @return $this |
||
| 930 | */ |
||
| 931 | 6 | public function includesReferenceTo($document) |
|
| 936 | |||
| 937 | /** |
||
| 938 | * @param string $documentName |
||
| 939 | * @return $this |
||
| 940 | */ |
||
| 941 | 1 | public function insert($documentName = null) |
|
| 948 | |||
| 949 | /** |
||
| 950 | * Set the $language option for $text criteria. |
||
| 951 | * |
||
| 952 | * This method must be called after text(). |
||
| 953 | * |
||
| 954 | * @see Expr::language() |
||
| 955 | * @see http://docs.mongodb.org/manual/reference/operator/text/ |
||
| 956 | * @param string $language |
||
| 957 | * @return $this |
||
| 958 | */ |
||
| 959 | 1 | public function language($language) |
|
| 964 | |||
| 965 | /** |
||
| 966 | * Set the limit for the query. |
||
| 967 | * |
||
| 968 | * This is only relevant for find queries and geoNear and mapReduce |
||
| 969 | * commands. |
||
| 970 | * |
||
| 971 | * @see Query::prepareCursor() |
||
| 972 | * @param integer $limit |
||
| 973 | * @return $this |
||
| 974 | */ |
||
| 975 | 2 | public function limit($limit) |
|
| 980 | |||
| 981 | /** |
||
| 982 | * Specify $lt criteria for the current field. |
||
| 983 | * |
||
| 984 | * @see Expr::lte() |
||
| 985 | * @see http://docs.mongodb.org/manual/reference/operator/lte/ |
||
| 986 | * @param mixed $value |
||
| 987 | * @return $this |
||
| 988 | */ |
||
| 989 | public function lt($value) |
||
| 994 | |||
| 995 | /** |
||
| 996 | * Specify $lte criteria for the current field. |
||
| 997 | * |
||
| 998 | * @see Expr::lte() |
||
| 999 | * @see http://docs.mongodb.org/manual/reference/operator/lte/ |
||
| 1000 | * @param mixed $value |
||
| 1001 | * @return $this |
||
| 1002 | */ |
||
| 1003 | public function lte($value) |
||
| 1008 | |||
| 1009 | /** |
||
| 1010 | * Change the query type to a mapReduce command. |
||
| 1011 | * |
||
| 1012 | * The "reduce" option is not specified when calling this method; it must |
||
| 1013 | * be set with the {@link Builder::reduce()} method. |
||
| 1014 | * |
||
| 1015 | * The "out" option defaults to inline, like {@link Builder::mapReduce()}. |
||
| 1016 | * |
||
| 1017 | * @see http://docs.mongodb.org/manual/reference/command/mapReduce/ |
||
| 1018 | * @param string|\MongoCode $map |
||
| 1019 | * @return $this |
||
| 1020 | */ |
||
| 1021 | 1 | public function map($map) |
|
| 1032 | |||
| 1033 | /** |
||
| 1034 | * Change the query type to a mapReduce command. |
||
| 1035 | * |
||
| 1036 | * @see http://docs.mongodb.org/manual/reference/command/mapReduce/ |
||
| 1037 | * @param string|\MongoCode $map |
||
| 1038 | * @param string|\MongoCode $reduce |
||
| 1039 | * @param array|string $out |
||
| 1040 | * @param array $options |
||
| 1041 | * @return $this |
||
| 1042 | */ |
||
| 1043 | 1 | public function mapReduce($map, $reduce, $out = ['inline' => true], array $options = []) |
|
| 1054 | |||
| 1055 | /** |
||
| 1056 | * Set additional options for a mapReduce command. |
||
| 1057 | * |
||
| 1058 | * @param array $options |
||
| 1059 | * @return $this |
||
| 1060 | * @throws \BadMethodCallException if the query is not a mapReduce command |
||
| 1061 | */ |
||
| 1062 | 1 | View Code Duplication | public function mapReduceOptions(array $options) |
| 1071 | |||
| 1072 | /** |
||
| 1073 | * Updates the value of the field to a specified value if the specified value is greater than the current value of the field. |
||
| 1074 | * |
||
| 1075 | * @see Expr::max() |
||
| 1076 | * @see http://docs.mongodb.org/manual/reference/operator/update/max/ |
||
| 1077 | * @param mixed $value |
||
| 1078 | * @return $this |
||
| 1079 | */ |
||
| 1080 | 1 | public function max($value) |
|
| 1085 | |||
| 1086 | /** |
||
| 1087 | * Specifies a cumulative time limit in milliseconds for processing operations on a cursor. |
||
| 1088 | * |
||
| 1089 | * @param int $ms |
||
| 1090 | * @return $this |
||
| 1091 | */ |
||
| 1092 | public function maxTimeMS($ms) |
||
| 1097 | |||
| 1098 | /** |
||
| 1099 | * Updates the value of the field to a specified value if the specified value is less than the current value of the field. |
||
| 1100 | * |
||
| 1101 | * @see Expr::min() |
||
| 1102 | * @see http://docs.mongodb.org/manual/reference/operator/update/min/ |
||
| 1103 | * @param mixed $value |
||
| 1104 | * @return $this |
||
| 1105 | */ |
||
| 1106 | 1 | public function min($value) |
|
| 1111 | |||
| 1112 | /** |
||
| 1113 | * Specify $mod criteria for the current field. |
||
| 1114 | * |
||
| 1115 | * @see Expr::mod() |
||
| 1116 | * @see http://docs.mongodb.org/manual/reference/operator/mod/ |
||
| 1117 | * @param float|integer $divisor |
||
| 1118 | * @param float|integer $remainder |
||
| 1119 | * @return $this |
||
| 1120 | */ |
||
| 1121 | 1 | public function mod($divisor, $remainder = 0) |
|
| 1126 | |||
| 1127 | /** |
||
| 1128 | * Multiply the current field. |
||
| 1129 | * |
||
| 1130 | * If the field does not exist, it will be set to 0. |
||
| 1131 | * |
||
| 1132 | * @see Expr::mul() |
||
| 1133 | * @see http://docs.mongodb.org/manual/reference/operator/mul/ |
||
| 1134 | * @param float|integer $value |
||
| 1135 | * @return $this |
||
| 1136 | */ |
||
| 1137 | 1 | public function mul($value) |
|
| 1142 | |||
| 1143 | /** |
||
| 1144 | * Set the "multiple" option for an update query. |
||
| 1145 | * |
||
| 1146 | * @param boolean $bool |
||
| 1147 | * @return $this |
||
| 1148 | * |
||
| 1149 | * @deprecated Deprecated in version 1.4 - use updateOne or updateMany instead |
||
| 1150 | */ |
||
| 1151 | public function multiple($bool = true) |
||
| 1156 | |||
| 1157 | /** |
||
| 1158 | * Add $near criteria to the query. |
||
| 1159 | * |
||
| 1160 | * A GeoJSON point may be provided as the first and only argument for |
||
| 1161 | * 2dsphere queries. This single parameter may be a GeoJSON point object or |
||
| 1162 | * an array corresponding to the point's JSON representation. |
||
| 1163 | * |
||
| 1164 | * @see Expr::near() |
||
| 1165 | * @see http://docs.mongodb.org/manual/reference/operator/near/ |
||
| 1166 | * @param float|array|Point $x |
||
| 1167 | * @param float $y |
||
| 1168 | * @return $this |
||
| 1169 | */ |
||
| 1170 | 1 | public function near($x, $y = null) |
|
| 1175 | |||
| 1176 | /** |
||
| 1177 | * Add $nearSphere criteria to the query. |
||
| 1178 | * |
||
| 1179 | * A GeoJSON point may be provided as the first and only argument for |
||
| 1180 | * 2dsphere queries. This single parameter may be a GeoJSON point object or |
||
| 1181 | * an array corresponding to the point's JSON representation. |
||
| 1182 | * |
||
| 1183 | * @see Expr::nearSphere() |
||
| 1184 | * @see http://docs.mongodb.org/manual/reference/operator/nearSphere/ |
||
| 1185 | * @param float|array|Point $x |
||
| 1186 | * @param float $y |
||
| 1187 | * @return $this |
||
| 1188 | */ |
||
| 1189 | 1 | public function nearSphere($x, $y = null) |
|
| 1194 | |||
| 1195 | /** |
||
| 1196 | * Negates an expression for the current field. |
||
| 1197 | * |
||
| 1198 | * You can create a new expression using the {@link Builder::expr()} method. |
||
| 1199 | * |
||
| 1200 | * @see Expr::not() |
||
| 1201 | * @see http://docs.mongodb.org/manual/reference/operator/not/ |
||
| 1202 | * @param array|Expr $expression |
||
| 1203 | * @return $this |
||
| 1204 | */ |
||
| 1205 | 3 | public function not($expression) |
|
| 1210 | |||
| 1211 | /** |
||
| 1212 | * Specify $ne criteria for the current field. |
||
| 1213 | * |
||
| 1214 | * @see Expr::notEqual() |
||
| 1215 | * @see http://docs.mongodb.org/manual/reference/operator/ne/ |
||
| 1216 | * @param mixed $value |
||
| 1217 | * @return $this |
||
| 1218 | */ |
||
| 1219 | 4 | public function notEqual($value) |
|
| 1224 | |||
| 1225 | /** |
||
| 1226 | * Specify $nin criteria for the current field. |
||
| 1227 | * |
||
| 1228 | * @see Expr::notIn() |
||
| 1229 | * @see http://docs.mongodb.org/manual/reference/operator/nin/ |
||
| 1230 | * @param array $values |
||
| 1231 | * @return $this |
||
| 1232 | */ |
||
| 1233 | 4 | public function notIn(array $values) |
|
| 1238 | |||
| 1239 | /** |
||
| 1240 | * Set the "out" option for a mapReduce command. |
||
| 1241 | * |
||
| 1242 | * @param array|string $out |
||
| 1243 | * @return $this |
||
| 1244 | * @throws \BadMethodCallException if the query is not a mapReduce command |
||
| 1245 | */ |
||
| 1246 | 1 | View Code Duplication | public function out($out) |
| 1255 | |||
| 1256 | /** |
||
| 1257 | * Remove the first element from the current array field. |
||
| 1258 | * |
||
| 1259 | * @see Expr::popFirst() |
||
| 1260 | * @see http://docs.mongodb.org/manual/reference/operator/pop/ |
||
| 1261 | * @return $this |
||
| 1262 | */ |
||
| 1263 | 2 | public function popFirst() |
|
| 1268 | |||
| 1269 | /** |
||
| 1270 | * Remove the last element from the current array field. |
||
| 1271 | * |
||
| 1272 | * @see Expr::popLast() |
||
| 1273 | * @see http://docs.mongodb.org/manual/reference/operator/pop/ |
||
| 1274 | * @return $this |
||
| 1275 | */ |
||
| 1276 | 1 | public function popLast() |
|
| 1281 | |||
| 1282 | /** |
||
| 1283 | * Use a primer to eagerly load all references in the current field. |
||
| 1284 | * |
||
| 1285 | * If $primer is true or a callable is provided, referenced documents for |
||
| 1286 | * this field will loaded into UnitOfWork immediately after the query is |
||
| 1287 | * executed. This will avoid multiple queries due to lazy initialization of |
||
| 1288 | * Proxy objects. |
||
| 1289 | * |
||
| 1290 | * If $primer is false, no priming will take place. That is also the default |
||
| 1291 | * behavior. |
||
| 1292 | * |
||
| 1293 | * If a custom callable is used, its signature should conform to the default |
||
| 1294 | * Closure defined in {@link ReferencePrimer::__construct()}. |
||
| 1295 | * |
||
| 1296 | * @param boolean|callable $primer |
||
| 1297 | * @return $this |
||
| 1298 | * @throws \InvalidArgumentException If $primer is not boolean or callable |
||
| 1299 | */ |
||
| 1300 | 25 | public function prime($primer = true) |
|
| 1319 | |||
| 1320 | /** |
||
| 1321 | * Remove all elements matching the given value or expression from the |
||
| 1322 | * current array field. |
||
| 1323 | * |
||
| 1324 | * @see Expr::pull() |
||
| 1325 | * @see http://docs.mongodb.org/manual/reference/operator/pull/ |
||
| 1326 | * @param mixed|Expr $valueOrExpression |
||
| 1327 | * @return $this |
||
| 1328 | */ |
||
| 1329 | 1 | public function pull($valueOrExpression) |
|
| 1334 | |||
| 1335 | /** |
||
| 1336 | * Remove all elements matching any of the given values from the current |
||
| 1337 | * array field. |
||
| 1338 | * |
||
| 1339 | * @see Expr::pullAll() |
||
| 1340 | * @see http://docs.mongodb.org/manual/reference/operator/pullAll/ |
||
| 1341 | * @param array $values |
||
| 1342 | * @return $this |
||
| 1343 | */ |
||
| 1344 | 1 | public function pullAll(array $values) |
|
| 1349 | |||
| 1350 | /** |
||
| 1351 | * Append one or more values to the current array field. |
||
| 1352 | * |
||
| 1353 | * If the field does not exist, it will be set to an array containing the |
||
| 1354 | * value(s) in the argument. If the field is not an array, the query |
||
| 1355 | * will yield an error. |
||
| 1356 | * |
||
| 1357 | * Multiple values may be specified by providing an Expr object and using |
||
| 1358 | * {@link Expr::each()}. {@link Expr::slice()} and {@link Expr::sort()} may |
||
| 1359 | * also be used to limit and order array elements, respectively. |
||
| 1360 | * |
||
| 1361 | * @see Expr::push() |
||
| 1362 | * @see http://docs.mongodb.org/manual/reference/operator/push/ |
||
| 1363 | * @see http://docs.mongodb.org/manual/reference/operator/each/ |
||
| 1364 | * @see http://docs.mongodb.org/manual/reference/operator/slice/ |
||
| 1365 | * @see http://docs.mongodb.org/manual/reference/operator/sort/ |
||
| 1366 | * @param mixed|Expr $valueOrExpression |
||
| 1367 | * @return $this |
||
| 1368 | */ |
||
| 1369 | 6 | public function push($valueOrExpression) |
|
| 1374 | |||
| 1375 | /** |
||
| 1376 | * Append multiple values to the current array field. |
||
| 1377 | * |
||
| 1378 | * If the field does not exist, it will be set to an array containing the |
||
| 1379 | * values in the argument. If the field is not an array, the query will |
||
| 1380 | * yield an error. |
||
| 1381 | * |
||
| 1382 | * This operator is deprecated in MongoDB 2.4. {@link Builder::push()} and |
||
| 1383 | * {@link Expr::each()} should be used in its place. |
||
| 1384 | * |
||
| 1385 | * @see Expr::pushAll() |
||
| 1386 | * @see http://docs.mongodb.org/manual/reference/operator/pushAll/ |
||
| 1387 | * @param array $values |
||
| 1388 | * @return $this |
||
| 1389 | */ |
||
| 1390 | 1 | public function pushAll(array $values) |
|
| 1395 | |||
| 1396 | /** |
||
| 1397 | * Specify $gte and $lt criteria for the current field. |
||
| 1398 | * |
||
| 1399 | * This method is shorthand for specifying $gte criteria on the lower bound |
||
| 1400 | * and $lt criteria on the upper bound. The upper bound is not inclusive. |
||
| 1401 | * |
||
| 1402 | * @see Expr::range() |
||
| 1403 | * @param mixed $start |
||
| 1404 | * @param mixed $end |
||
| 1405 | * @return $this |
||
| 1406 | */ |
||
| 1407 | 3 | public function range($start, $end) |
|
| 1412 | |||
| 1413 | /** |
||
| 1414 | * @param bool $bool |
||
| 1415 | * @return $this |
||
| 1416 | */ |
||
| 1417 | 2 | public function readOnly($bool = true) |
|
| 1422 | |||
| 1423 | /** |
||
| 1424 | * Set the "reduce" option for a mapReduce or group command. |
||
| 1425 | * |
||
| 1426 | * @param string|\MongoCode $reduce |
||
| 1427 | * @return $this |
||
| 1428 | * @throws \BadMethodCallException if the query is not a mapReduce or group command |
||
| 1429 | */ |
||
| 1430 | 2 | View Code Duplication | public function reduce($reduce) |
| 1447 | |||
| 1448 | /** |
||
| 1449 | * @param object $document |
||
| 1450 | * @return $this |
||
| 1451 | */ |
||
| 1452 | 10 | public function references($document) |
|
| 1457 | |||
| 1458 | /** |
||
| 1459 | * @param bool $bool |
||
| 1460 | * @return $this |
||
| 1461 | */ |
||
| 1462 | 5 | public function refresh($bool = true) |
|
| 1467 | |||
| 1468 | /** |
||
| 1469 | * @param string $documentName |
||
| 1470 | * @return $this |
||
| 1471 | */ |
||
| 1472 | 1 | public function remove($documentName = null) |
|
| 1479 | |||
| 1480 | /** |
||
| 1481 | * Rename the current field. |
||
| 1482 | * |
||
| 1483 | * @see Expr::rename() |
||
| 1484 | * @see http://docs.mongodb.org/manual/reference/operator/rename/ |
||
| 1485 | * @param string $name |
||
| 1486 | * @return $this |
||
| 1487 | */ |
||
| 1488 | public function rename($name) |
||
| 1493 | |||
| 1494 | /** |
||
| 1495 | * @param bool $bool |
||
| 1496 | * @return $this |
||
| 1497 | */ |
||
| 1498 | 4 | public function returnNew($bool = true) |
|
| 1505 | |||
| 1506 | /** |
||
| 1507 | * Set one or more fields to be included in the query projection. |
||
| 1508 | * |
||
| 1509 | * @param array|string $fieldName,... |
||
| 1510 | * @return $this |
||
| 1511 | */ |
||
| 1512 | 19 | View Code Duplication | public function select($fieldName = null) |
| 1526 | |||
| 1527 | /** |
||
| 1528 | * Select only matching embedded documents in an array field for the query |
||
| 1529 | * projection. |
||
| 1530 | * |
||
| 1531 | * @see http://docs.mongodb.org/manual/reference/projection/elemMatch/ |
||
| 1532 | * @param string $fieldName |
||
| 1533 | * @param array|Expr $expression |
||
| 1534 | * @return $this |
||
| 1535 | */ |
||
| 1536 | 2 | public function selectElemMatch($fieldName, $expression) |
|
| 1544 | |||
| 1545 | /** |
||
| 1546 | * Select a metadata field for the query projection. |
||
| 1547 | * |
||
| 1548 | * @see http://docs.mongodb.org/master/reference/operator/projection/meta/ |
||
| 1549 | * @param string $fieldName |
||
| 1550 | * @param string $metaDataKeyword |
||
| 1551 | * @return $this |
||
| 1552 | */ |
||
| 1553 | 2 | public function selectMeta($fieldName, $metaDataKeyword) |
|
| 1558 | |||
| 1559 | /** |
||
| 1560 | * Select a slice of an array field for the query projection. |
||
| 1561 | * |
||
| 1562 | * The $countOrSkip parameter has two very different meanings, depending on |
||
| 1563 | * whether or not $limit is provided. See the MongoDB documentation for more |
||
| 1564 | * information. |
||
| 1565 | * |
||
| 1566 | * @see http://docs.mongodb.org/manual/reference/projection/slice/ |
||
| 1567 | * @param string $fieldName |
||
| 1568 | * @param integer $countOrSkip Count parameter, or skip if limit is specified |
||
| 1569 | * @param integer $limit Limit parameter used in conjunction with skip |
||
| 1570 | * @return $this |
||
| 1571 | */ |
||
| 1572 | 3 | public function selectSlice($fieldName, $countOrSkip, $limit = null) |
|
| 1581 | |||
| 1582 | /** |
||
| 1583 | * Set the current field to a value. |
||
| 1584 | * |
||
| 1585 | * This is only relevant for insert, update, or findAndUpdate queries. For |
||
| 1586 | * update and findAndUpdate queries, the $atomic parameter will determine |
||
| 1587 | * whether or not a $set operator is used. |
||
| 1588 | * |
||
| 1589 | * @see Expr::set() |
||
| 1590 | * @see http://docs.mongodb.org/manual/reference/operator/set/ |
||
| 1591 | * @param mixed $value |
||
| 1592 | * @param boolean $atomic |
||
| 1593 | * @return $this |
||
| 1594 | */ |
||
| 1595 | 16 | public function set($value, $atomic = true) |
|
| 1600 | |||
| 1601 | /** |
||
| 1602 | * Set the expression's "new object". |
||
| 1603 | * |
||
| 1604 | * @see Expr::setNewObj() |
||
| 1605 | * @param array $newObj |
||
| 1606 | * @return $this |
||
| 1607 | */ |
||
| 1608 | public function setNewObj(array $newObj) |
||
| 1613 | |||
| 1614 | /** |
||
| 1615 | * Set the current field to the value if the document is inserted in an |
||
| 1616 | * upsert operation. |
||
| 1617 | * |
||
| 1618 | * If an update operation with upsert: true results in an insert of a |
||
| 1619 | * document, then $setOnInsert assigns the specified values to the fields in |
||
| 1620 | * the document. If the update operation does not result in an insert, |
||
| 1621 | * $setOnInsert does nothing. |
||
| 1622 | * |
||
| 1623 | * @see Expr::setOnInsert() |
||
| 1624 | * @see https://docs.mongodb.org/manual/reference/operator/update/setOnInsert/ |
||
| 1625 | * @param mixed $value |
||
| 1626 | * @return $this |
||
| 1627 | */ |
||
| 1628 | 2 | public function setOnInsert($value) |
|
| 1633 | |||
| 1634 | /** |
||
| 1635 | * Set the read preference for the query. |
||
| 1636 | * |
||
| 1637 | * This is only relevant for read-only queries and commands. |
||
| 1638 | * |
||
| 1639 | * @see http://docs.mongodb.org/manual/core/read-preference/ |
||
| 1640 | * @param ReadPreference $readPreference |
||
| 1641 | * @return $this |
||
| 1642 | */ |
||
| 1643 | 6 | public function setReadPreference(ReadPreference $readPreference) |
|
| 1648 | |||
| 1649 | /** |
||
| 1650 | * Set the expression's query criteria. |
||
| 1651 | * |
||
| 1652 | * @see Expr::setQuery() |
||
| 1653 | * @param array $query |
||
| 1654 | * @return $this |
||
| 1655 | */ |
||
| 1656 | 18 | public function setQueryArray(array $query) |
|
| 1661 | |||
| 1662 | /** |
||
| 1663 | * Specify $size criteria for the current field. |
||
| 1664 | * |
||
| 1665 | * @see Expr::size() |
||
| 1666 | * @see http://docs.mongodb.org/manual/reference/operator/size/ |
||
| 1667 | * @param integer $size |
||
| 1668 | * @return $this |
||
| 1669 | */ |
||
| 1670 | 1 | public function size($size) |
|
| 1675 | |||
| 1676 | /** |
||
| 1677 | * Set the skip for the query cursor. |
||
| 1678 | * |
||
| 1679 | * This is only relevant for find queries, or mapReduce queries that store |
||
| 1680 | * results in an output collecton and return a cursor. |
||
| 1681 | * |
||
| 1682 | * @see Query::prepareCursor() |
||
| 1683 | * @param integer $skip |
||
| 1684 | * @return $this |
||
| 1685 | */ |
||
| 1686 | public function skip($skip) |
||
| 1691 | |||
| 1692 | /** |
||
| 1693 | * Set the snapshot cursor flag. |
||
| 1694 | * |
||
| 1695 | * @param boolean $bool |
||
| 1696 | * @return $this |
||
| 1697 | */ |
||
| 1698 | public function snapshot($bool = true) |
||
| 1703 | |||
| 1704 | /** |
||
| 1705 | * Set one or more field/order pairs on which to sort the query. |
||
| 1706 | * |
||
| 1707 | * If sorting by multiple fields, the first argument should be an array of |
||
| 1708 | * field name (key) and order (value) pairs. |
||
| 1709 | * |
||
| 1710 | * @param array|string $fieldName Field name or array of field/order pairs |
||
| 1711 | * @param int|string $order Field order (if one field is specified) |
||
| 1712 | * @return $this |
||
| 1713 | */ |
||
| 1714 | 31 | public function sort($fieldName, $order = 1) |
|
| 1731 | |||
| 1732 | /** |
||
| 1733 | * Specify a projected metadata field on which to sort the query. |
||
| 1734 | * |
||
| 1735 | * Sort order is not configurable for metadata fields. Sorting by a metadata |
||
| 1736 | * field requires the same field and $meta expression to exist in the |
||
| 1737 | * projection document. This method will call {@link Builder::selectMeta()} |
||
| 1738 | * if the field is not already set in the projection. |
||
| 1739 | * |
||
| 1740 | * @see http://docs.mongodb.org/master/reference/operator/projection/meta/#sort |
||
| 1741 | * @param string $fieldName Field name of the projected metadata |
||
| 1742 | * @param string $metaDataKeyword |
||
| 1743 | * @return $this |
||
| 1744 | */ |
||
| 1745 | 2 | public function sortMeta($fieldName, $metaDataKeyword) |
|
| 1759 | |||
| 1760 | /** |
||
| 1761 | * Specify $text criteria for the current field. |
||
| 1762 | * |
||
| 1763 | * The $language option may be set with {@link Builder::language()}. |
||
| 1764 | * |
||
| 1765 | * @see Expr::text() |
||
| 1766 | * @see http://docs.mongodb.org/master/reference/operator/query/text/ |
||
| 1767 | * @param string $search |
||
| 1768 | * @return $this |
||
| 1769 | */ |
||
| 1770 | 1 | public function text($search) |
|
| 1775 | |||
| 1776 | /** |
||
| 1777 | * Specify $type criteria for the current field. |
||
| 1778 | * |
||
| 1779 | * @see Expr::type() |
||
| 1780 | * @see http://docs.mongodb.org/manual/reference/operator/type/ |
||
| 1781 | * @param integer $type |
||
| 1782 | * @return $this |
||
| 1783 | */ |
||
| 1784 | 2 | public function type($type) |
|
| 1789 | |||
| 1790 | /** |
||
| 1791 | * Unset the current field. |
||
| 1792 | * |
||
| 1793 | * The field will be removed from the document (not set to null). |
||
| 1794 | * |
||
| 1795 | * @see Expr::unsetField() |
||
| 1796 | * @see http://docs.mongodb.org/manual/reference/operator/unset/ |
||
| 1797 | * @return $this |
||
| 1798 | */ |
||
| 1799 | 4 | public function unsetField() |
|
| 1804 | |||
| 1805 | /** |
||
| 1806 | * @param string $documentName |
||
| 1807 | * @return $this |
||
| 1808 | */ |
||
| 1809 | 21 | View Code Duplication | public function updateOne($documentName = null) |
| 1817 | |||
| 1818 | /** |
||
| 1819 | * @param string $documentName |
||
| 1820 | * @return $this |
||
| 1821 | */ |
||
| 1822 | 3 | View Code Duplication | public function updateMany($documentName = null) |
| 1830 | |||
| 1831 | /** |
||
| 1832 | * Set the "upsert" option for an update or findAndUpdate query. |
||
| 1833 | * |
||
| 1834 | * @param boolean $bool |
||
| 1835 | * @return $this |
||
| 1836 | */ |
||
| 1837 | 7 | public function upsert($bool = true) |
|
| 1842 | |||
| 1843 | /** |
||
| 1844 | * Specify a JavaScript expression to use for matching documents. |
||
| 1845 | * |
||
| 1846 | * @see Expr::where() |
||
| 1847 | * @see http://docs.mongodb.org/manual/reference/operator/where/ |
||
| 1848 | * @param string|\MongoCode $javascript |
||
| 1849 | * @return $this |
||
| 1850 | */ |
||
| 1851 | 3 | public function where($javascript) |
|
| 1856 | |||
| 1857 | /** |
||
| 1858 | * Add $within criteria with a $box shape to the query. |
||
| 1859 | * |
||
| 1860 | * @deprecated 1.1 MongoDB 2.4 deprecated $within in favor of $geoWithin |
||
| 1861 | * @see Builder::geoWithinBox() |
||
| 1862 | * @see Expr::withinBox() |
||
| 1863 | * @see http://docs.mongodb.org/manual/reference/operator/box/ |
||
| 1864 | * @param float $x1 |
||
| 1865 | * @param float $y1 |
||
| 1866 | * @param float $x2 |
||
| 1867 | * @param float $y2 |
||
| 1868 | * @return $this |
||
| 1869 | */ |
||
| 1870 | 1 | public function withinBox($x1, $y1, $x2, $y2) |
|
| 1875 | |||
| 1876 | /** |
||
| 1877 | * Add $within criteria with a $center shape to the query. |
||
| 1878 | * |
||
| 1879 | * @deprecated 1.1 MongoDB 2.4 deprecated $within in favor of $geoWithin |
||
| 1880 | * @see Builder::geoWithinCenter() |
||
| 1881 | * @see Expr::withinCenter() |
||
| 1882 | * @see http://docs.mongodb.org/manual/reference/operator/center/ |
||
| 1883 | * @param float $x |
||
| 1884 | * @param float $y |
||
| 1885 | * @param float $radius |
||
| 1886 | * @return $this |
||
| 1887 | */ |
||
| 1888 | 1 | public function withinCenter($x, $y, $radius) |
|
| 1893 | |||
| 1894 | /** |
||
| 1895 | * Add $within criteria with a $centerSphere shape to the query. |
||
| 1896 | * |
||
| 1897 | * @deprecated 1.1 MongoDB 2.4 deprecated $within in favor of $geoWithin |
||
| 1898 | * @see Builder::geoWithinCenterSphere() |
||
| 1899 | * @see Expr::withinCenterSphere() |
||
| 1900 | * @see http://docs.mongodb.org/manual/reference/operator/centerSphere/ |
||
| 1901 | * @param float $x |
||
| 1902 | * @param float $y |
||
| 1903 | * @param float $radius |
||
| 1904 | * @return $this |
||
| 1905 | */ |
||
| 1906 | 1 | public function withinCenterSphere($x, $y, $radius) |
|
| 1911 | |||
| 1912 | /** |
||
| 1913 | * Add $within criteria with a $polygon shape to the query. |
||
| 1914 | * |
||
| 1915 | * Point coordinates are in x, y order (easting, northing for projected |
||
| 1916 | * coordinates, longitude, latitude for geographic coordinates). |
||
| 1917 | * |
||
| 1918 | * The last point coordinate is implicitly connected with the first. |
||
| 1919 | * |
||
| 1920 | * @deprecated 1.1 MongoDB 2.4 deprecated $within in favor of $geoWithin |
||
| 1921 | * @see Builder::geoWithinPolygon() |
||
| 1922 | * @see Expr::withinPolygon() |
||
| 1923 | * @see http://docs.mongodb.org/manual/reference/operator/polygon/ |
||
| 1924 | * @param array $point,... Three or more point coordinate tuples |
||
| 1925 | * @return $this |
||
| 1926 | */ |
||
| 1927 | 1 | public function withinPolygon(/* array($x1, $y1), array($x2, $y2), ... */) |
|
| 1932 | |||
| 1933 | /** |
||
| 1934 | * Get Discriminator Values |
||
| 1935 | * |
||
| 1936 | * @param \Traversable $classNames |
||
| 1937 | * @return array an array of discriminatorValues (mixed type) |
||
| 1938 | * @throws \InvalidArgumentException if the number of found collections > 1 |
||
| 1939 | */ |
||
| 1940 | 2 | private function getDiscriminatorValues($classNames) |
|
| 1955 | |||
| 1956 | /** |
||
| 1957 | * @param string[]|string $documentName an array of document names or just one. |
||
| 1958 | */ |
||
| 1959 | 290 | private function setDocumentName($documentName) |
|
| 1985 | } |
||
| 1986 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.