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 |
||
| 17 | class Builder |
||
| 18 | { |
||
| 19 | /** |
||
| 20 | * The DocumentManager instance for this query |
||
| 21 | * |
||
| 22 | * @var DocumentManager |
||
| 23 | */ |
||
| 24 | private $dm; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * The ClassMetadata instance. |
||
| 28 | * |
||
| 29 | * @var \Doctrine\ODM\MongoDB\Mapping\ClassMetadata |
||
| 30 | */ |
||
| 31 | private $class; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * The current field we are operating on. |
||
| 35 | * |
||
| 36 | * @todo Change this to private once ODM requires doctrine/mongodb 1.1+ |
||
| 37 | * @var string |
||
| 38 | */ |
||
| 39 | protected $currentField; |
||
| 40 | |||
| 41 | /** |
||
| 42 | * Whether or not to hydrate the data to documents. |
||
| 43 | * |
||
| 44 | * @var boolean |
||
| 45 | */ |
||
| 46 | private $hydrate = true; |
||
| 47 | |||
| 48 | /** |
||
| 49 | * Whether or not to refresh the data for documents that are already in the identity map. |
||
| 50 | * |
||
| 51 | * @var boolean |
||
| 52 | */ |
||
| 53 | private $refresh = false; |
||
| 54 | |||
| 55 | /** |
||
| 56 | * Array of primer Closure instances. |
||
| 57 | * |
||
| 58 | * @var array |
||
| 59 | */ |
||
| 60 | private $primers = array(); |
||
| 61 | |||
| 62 | /** |
||
| 63 | * Whether or not to register documents in UnitOfWork. |
||
| 64 | * |
||
| 65 | * @var bool |
||
| 66 | */ |
||
| 67 | private $readOnly; |
||
| 68 | |||
| 69 | /** |
||
| 70 | * The Collection instance. |
||
| 71 | * |
||
| 72 | * @var Collection |
||
| 73 | */ |
||
| 74 | private $collection; |
||
| 75 | |||
| 76 | /** |
||
| 77 | * Array containing the query data. |
||
| 78 | * |
||
| 79 | * @var array |
||
| 80 | */ |
||
| 81 | private $query = ['type' => Query::TYPE_FIND]; |
||
| 82 | |||
| 83 | /** |
||
| 84 | * The Expr instance used for building this query. |
||
| 85 | * |
||
| 86 | * This object includes the query criteria and the "new object" used for |
||
| 87 | * insert and update queries. |
||
| 88 | * |
||
| 89 | * @var Expr $expr |
||
| 90 | */ |
||
| 91 | private $expr; |
||
| 92 | |||
| 93 | /** |
||
| 94 | * Construct a Builder |
||
| 95 | * |
||
| 96 | * @param DocumentManager $dm |
||
| 97 | * @param string[]|string|null $documentName (optional) an array of document names, the document name, or none |
||
| 98 | */ |
||
| 99 | 291 | public function __construct(DocumentManager $dm, $documentName = null) |
|
| 107 | |||
| 108 | 1 | public function __clone() |
|
| 112 | |||
| 113 | /** |
||
| 114 | * Add one or more $and clauses to the current query. |
||
| 115 | * |
||
| 116 | * You can create a new expression using the {@link Builder::expr()} method. |
||
| 117 | * |
||
| 118 | * @see Expr::addAnd() |
||
| 119 | * @see http://docs.mongodb.org/manual/reference/operator/and/ |
||
| 120 | * @param array|Expr $expression |
||
| 121 | * @return $this |
||
| 122 | */ |
||
| 123 | 4 | public function addAnd($expression /* , $expression2, ... */) |
|
| 128 | |||
| 129 | /** |
||
| 130 | * Append multiple values to the current array field only if they do not |
||
| 131 | * already exist in the array. |
||
| 132 | * |
||
| 133 | * If the field does not exist, it will be set to an array containing the |
||
| 134 | * unique values in the argument. If the field is not an array, the query |
||
| 135 | * will yield an error. |
||
| 136 | * |
||
| 137 | * @deprecated 1.1 Use {@link Builder::addToSet()} with {@link Expr::each()}; Will be removed in 2.0 |
||
| 138 | * @see Expr::addManyToSet() |
||
| 139 | * @see http://docs.mongodb.org/manual/reference/operator/addToSet/ |
||
| 140 | * @see http://docs.mongodb.org/manual/reference/operator/each/ |
||
| 141 | * @param array $values |
||
| 142 | * @return $this |
||
| 143 | */ |
||
| 144 | 1 | public function addManyToSet(array $values) |
|
| 149 | |||
| 150 | /** |
||
| 151 | * Add one or more $nor clauses to the current query. |
||
| 152 | * |
||
| 153 | * You can create a new expression using the {@link Builder::expr()} method. |
||
| 154 | * |
||
| 155 | * @see Expr::addNor() |
||
| 156 | * @see http://docs.mongodb.org/manual/reference/operator/nor/ |
||
| 157 | * @param array|Expr $expression |
||
| 158 | * @return $this |
||
| 159 | */ |
||
| 160 | 3 | public function addNor($expression /* , $expression2, ... */) |
|
| 165 | |||
| 166 | /** |
||
| 167 | * Add one or more $or clauses to the current query. |
||
| 168 | * |
||
| 169 | * You can create a new expression using the {@link Builder::expr()} method. |
||
| 170 | * |
||
| 171 | * @see Expr::addOr() |
||
| 172 | * @see http://docs.mongodb.org/manual/reference/operator/or/ |
||
| 173 | * @param array|Expr $expression |
||
| 174 | * @return $this |
||
| 175 | */ |
||
| 176 | 6 | public function addOr($expression /* , $expression2, ... */) |
|
| 181 | |||
| 182 | /** |
||
| 183 | * Append one or more values to the current array field only if they do not |
||
| 184 | * already exist in the array. |
||
| 185 | * |
||
| 186 | * If the field does not exist, it will be set to an array containing the |
||
| 187 | * unique value(s) in the argument. If the field is not an array, the query |
||
| 188 | * will yield an error. |
||
| 189 | * |
||
| 190 | * Multiple values may be specified by provided an Expr object and using |
||
| 191 | * {@link Expr::each()}. |
||
| 192 | * |
||
| 193 | * @see Expr::addToSet() |
||
| 194 | * @see http://docs.mongodb.org/manual/reference/operator/addToSet/ |
||
| 195 | * @see http://docs.mongodb.org/manual/reference/operator/each/ |
||
| 196 | * @param mixed|Expr $valueOrExpression |
||
| 197 | * @return $this |
||
| 198 | */ |
||
| 199 | 5 | public function addToSet($valueOrExpression) |
|
| 204 | |||
| 205 | /** |
||
| 206 | * Specify $all criteria for the current field. |
||
| 207 | * |
||
| 208 | * @see Expr::all() |
||
| 209 | * @see http://docs.mongodb.org/manual/reference/operator/all/ |
||
| 210 | * @param array $values |
||
| 211 | * @return $this |
||
| 212 | */ |
||
| 213 | 3 | public function all(array $values) |
|
| 218 | |||
| 219 | /** |
||
| 220 | * Apply a bitwise and operation on the current field. |
||
| 221 | * |
||
| 222 | * @see Expr::bitAnd() |
||
| 223 | * @see http://docs.mongodb.org/manual/reference/operator/update/bit/ |
||
| 224 | * @param int $value |
||
| 225 | * @return $this |
||
| 226 | */ |
||
| 227 | 1 | public function bitAnd($value) |
|
| 232 | |||
| 233 | /** |
||
| 234 | * Apply a bitwise or operation on the current field. |
||
| 235 | * |
||
| 236 | * @see Expr::bitOr() |
||
| 237 | * @see http://docs.mongodb.org/manual/reference/operator/update/bit/ |
||
| 238 | * @param int $value |
||
| 239 | * @return $this |
||
| 240 | */ |
||
| 241 | 1 | public function bitOr($value) |
|
| 246 | |||
| 247 | /** |
||
| 248 | * Matches documents where all of the bit positions given by the query are |
||
| 249 | * clear. |
||
| 250 | * |
||
| 251 | * @see Expr::bitsAllClear() |
||
| 252 | * @see https://docs.mongodb.org/manual/reference/operator/query/bitsAllClear/ |
||
| 253 | * @param int|array|\MongoBinData $value |
||
| 254 | * @return $this |
||
| 255 | */ |
||
| 256 | 1 | public function bitsAllClear($value) |
|
| 261 | |||
| 262 | /** |
||
| 263 | * Matches documents where all of the bit positions given by the query are |
||
| 264 | * set. |
||
| 265 | * |
||
| 266 | * @see Expr::bitsAllSet() |
||
| 267 | * @see https://docs.mongodb.org/manual/reference/operator/query/bitsAllSet/ |
||
| 268 | * @param int|array|\MongoBinData $value |
||
| 269 | * @return $this |
||
| 270 | */ |
||
| 271 | 1 | public function bitsAllSet($value) |
|
| 276 | |||
| 277 | /** |
||
| 278 | * Matches documents where any of the bit positions given by the query are |
||
| 279 | * clear. |
||
| 280 | * |
||
| 281 | * @see Expr::bitsAnyClear() |
||
| 282 | * @see https://docs.mongodb.org/manual/reference/operator/query/bitsAnyClear/ |
||
| 283 | * @param int|array|\MongoBinData $value |
||
| 284 | * @return $this |
||
| 285 | */ |
||
| 286 | 1 | public function bitsAnyClear($value) |
|
| 291 | |||
| 292 | /** |
||
| 293 | * Matches documents where any of the bit positions given by the query are |
||
| 294 | * set. |
||
| 295 | * |
||
| 296 | * @see Expr::bitsAnySet() |
||
| 297 | * @see https://docs.mongodb.org/manual/reference/operator/query/bitsAnySet/ |
||
| 298 | * @param int|array|\MongoBinData $value |
||
| 299 | * @return $this |
||
| 300 | */ |
||
| 301 | 1 | public function bitsAnySet($value) |
|
| 306 | |||
| 307 | /** |
||
| 308 | * Apply a bitwise xor operation on the current field. |
||
| 309 | * |
||
| 310 | * @see Expr::bitXor() |
||
| 311 | * @see http://docs.mongodb.org/manual/reference/operator/update/bit/ |
||
| 312 | * @param int $value |
||
| 313 | * @return $this |
||
| 314 | */ |
||
| 315 | 1 | public function bitXor($value) |
|
| 320 | |||
| 321 | /** |
||
| 322 | * A boolean flag to enable or disable case sensitive search for $text |
||
| 323 | * criteria. |
||
| 324 | * |
||
| 325 | * This method must be called after text(). |
||
| 326 | * |
||
| 327 | * @see Expr::caseSensitive() |
||
| 328 | * @see http://docs.mongodb.org/manual/reference/operator/text/ |
||
| 329 | * @param bool $caseSensitive |
||
| 330 | * @return $this |
||
| 331 | * @throws \BadMethodCallException if the query does not already have $text criteria |
||
| 332 | * |
||
| 333 | * @since 1.3 |
||
| 334 | */ |
||
| 335 | 1 | public function caseSensitive($caseSensitive) |
|
| 340 | |||
| 341 | /** |
||
| 342 | * Associates a comment to any expression taking a query predicate. |
||
| 343 | * |
||
| 344 | * @see Expr::comment() |
||
| 345 | * @see http://docs.mongodb.org/manual/reference/operator/query/comment/ |
||
| 346 | * @param string $comment |
||
| 347 | * @return $this |
||
| 348 | */ |
||
| 349 | 1 | public function comment($comment) |
|
| 354 | |||
| 355 | /** |
||
| 356 | * Change the query type to count. |
||
| 357 | * |
||
| 358 | * @return $this |
||
| 359 | */ |
||
| 360 | public function count() |
||
| 365 | |||
| 366 | /** |
||
| 367 | * Sets the value of the current field to the current date, either as a date or a timestamp. |
||
| 368 | * |
||
| 369 | * @see Expr::currentDate() |
||
| 370 | * @see http://docs.mongodb.org/manual/reference/operator/currentDate/ |
||
| 371 | * @param string $type |
||
| 372 | * @return $this |
||
| 373 | */ |
||
| 374 | 3 | public function currentDate($type = 'date') |
|
| 379 | |||
| 380 | /** |
||
| 381 | * Return an array of information about the Builder state for debugging. |
||
| 382 | * |
||
| 383 | * The $name parameter may be used to return a specific key from the |
||
| 384 | * internal $query array property. If omitted, the entire array will be |
||
| 385 | * returned. |
||
| 386 | * |
||
| 387 | * @param string $name |
||
| 388 | * @return mixed |
||
| 389 | */ |
||
| 390 | 28 | public function debug($name = null) |
|
| 394 | |||
| 395 | /** |
||
| 396 | * A boolean flag to enable or disable diacritic sensitive search for $text |
||
| 397 | * criteria. |
||
| 398 | * |
||
| 399 | * This method must be called after text(). |
||
| 400 | * |
||
| 401 | * @see Builder::diacriticSensitive() |
||
| 402 | * @see http://docs.mongodb.org/manual/reference/operator/text/ |
||
| 403 | * @param bool $diacriticSensitive |
||
| 404 | * @return $this |
||
| 405 | * @throws \BadMethodCallException if the query does not already have $text criteria |
||
| 406 | * |
||
| 407 | * @since 1.3 |
||
| 408 | */ |
||
| 409 | 1 | public function diacriticSensitive($diacriticSensitive) |
|
| 414 | |||
| 415 | /** |
||
| 416 | * Change the query type to a distinct command. |
||
| 417 | * |
||
| 418 | * @see http://docs.mongodb.org/manual/reference/command/distinct/ |
||
| 419 | * @param string $field |
||
| 420 | * @return $this |
||
| 421 | */ |
||
| 422 | 2 | public function distinct($field) |
|
| 428 | |||
| 429 | /** |
||
| 430 | * Set whether the query should return its result as an EagerCursor. |
||
| 431 | * |
||
| 432 | * @param boolean $bool |
||
| 433 | * @return $this |
||
| 434 | */ |
||
| 435 | 5 | public function eagerCursor($bool = true) |
|
| 444 | |||
| 445 | /** |
||
| 446 | * Specify $elemMatch criteria for the current field. |
||
| 447 | * |
||
| 448 | * You can create a new expression using the {@link Builder::expr()} method. |
||
| 449 | * |
||
| 450 | * @see Expr::elemMatch() |
||
| 451 | * @see http://docs.mongodb.org/manual/reference/operator/elemMatch/ |
||
| 452 | * @param array|Expr $expression |
||
| 453 | * @return $this |
||
| 454 | */ |
||
| 455 | 6 | public function elemMatch($expression) |
|
| 460 | |||
| 461 | /** |
||
| 462 | * Specify an equality match for the current field. |
||
| 463 | * |
||
| 464 | * @see Expr::equals() |
||
| 465 | * @param mixed $value |
||
| 466 | * @return $this |
||
| 467 | */ |
||
| 468 | 75 | public function equals($value) |
|
| 473 | |||
| 474 | /** |
||
| 475 | * Set one or more fields to be excluded from the query projection. |
||
| 476 | * |
||
| 477 | * If fields have been selected for inclusion, only the "_id" field may be |
||
| 478 | * excluded. |
||
| 479 | * |
||
| 480 | * @param array|string $fieldName,... |
||
| 481 | * @return $this |
||
| 482 | */ |
||
| 483 | 6 | View Code Duplication | public function exclude($fieldName = null) |
| 497 | |||
| 498 | /** |
||
| 499 | * Specify $exists criteria for the current field. |
||
| 500 | * |
||
| 501 | * @see Expr::exists() |
||
| 502 | * @see http://docs.mongodb.org/manual/reference/operator/exists/ |
||
| 503 | * @param boolean $bool |
||
| 504 | * @return $this |
||
| 505 | */ |
||
| 506 | 5 | public function exists($bool) |
|
| 511 | |||
| 512 | /** |
||
| 513 | * Create a new Expr instance that can be used as an expression with the Builder |
||
| 514 | * |
||
| 515 | * @return Expr $expr |
||
| 516 | */ |
||
| 517 | 26 | public function expr() |
|
| 524 | |||
| 525 | /** |
||
| 526 | * Set the current field to operate on. |
||
| 527 | * |
||
| 528 | * @param string $field |
||
| 529 | * @return $this |
||
| 530 | */ |
||
| 531 | 144 | public function field($field) |
|
| 538 | |||
| 539 | /** |
||
| 540 | * Set the "finalize" option for a mapReduce or group command. |
||
| 541 | * |
||
| 542 | * @param string|\MongoCode $finalize |
||
| 543 | * @return $this |
||
| 544 | * @throws \BadMethodCallException if the query is not a mapReduce or group command |
||
| 545 | */ |
||
| 546 | 2 | View Code Duplication | public function finalize($finalize) |
| 547 | { |
||
| 548 | 2 | switch ($this->query['type']) { |
|
| 549 | case Query::TYPE_MAP_REDUCE: |
||
| 550 | 1 | $this->query['mapReduce']['options']['finalize'] = $finalize; |
|
| 551 | 1 | break; |
|
| 552 | |||
| 553 | case Query::TYPE_GROUP: |
||
| 554 | $this->query['group']['options']['finalize'] = $finalize; |
||
| 555 | break; |
||
| 556 | |||
| 557 | default: |
||
| 558 | 1 | throw new \BadMethodCallException('mapReduce(), map() or group() must be called before finalize()'); |
|
| 559 | } |
||
| 560 | |||
| 561 | 1 | return $this; |
|
| 562 | } |
||
| 563 | |||
| 564 | /** |
||
| 565 | * Change the query type to find and optionally set and change the class being queried. |
||
| 566 | * |
||
| 567 | * @param string $documentName |
||
| 568 | * @return $this |
||
| 569 | */ |
||
| 570 | 12 | public function find($documentName = null) |
|
| 577 | |||
| 578 | /** |
||
| 579 | * @param string $documentName |
||
| 580 | * @return $this |
||
| 581 | */ |
||
| 582 | 1 | public function findAndRemove($documentName = null) |
|
| 589 | |||
| 590 | /** |
||
| 591 | * @param string $documentName |
||
| 592 | * @return $this |
||
| 593 | */ |
||
| 594 | 13 | public function findAndUpdate($documentName = null) |
|
| 601 | |||
| 602 | /** |
||
| 603 | * Add $geoIntersects criteria with a GeoJSON geometry to the query. |
||
| 604 | * |
||
| 605 | * The geometry parameter GeoJSON object or an array corresponding to the |
||
| 606 | * geometry's JSON representation. |
||
| 607 | * |
||
| 608 | * @see Expr::geoIntersects() |
||
| 609 | * @see http://docs.mongodb.org/manual/reference/operator/geoIntersects/ |
||
| 610 | * @param array|Geometry $geometry |
||
| 611 | * @return $this |
||
| 612 | */ |
||
| 613 | 1 | public function geoIntersects($geometry) |
|
| 618 | |||
| 619 | /** |
||
| 620 | * Add $geoWithin 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::geoWithin() |
||
| 626 | * @see http://docs.mongodb.org/manual/reference/operator/geoWithin/ |
||
| 627 | * @param array|Geometry $geometry |
||
| 628 | * @return $this |
||
| 629 | */ |
||
| 630 | 1 | public function geoWithin($geometry) |
|
| 635 | |||
| 636 | /** |
||
| 637 | * Add $geoWithin criteria with a $box shape to the query. |
||
| 638 | * |
||
| 639 | * A rectangular polygon will be constructed from a pair of coordinates |
||
| 640 | * corresponding to the bottom left and top right corners. |
||
| 641 | * |
||
| 642 | * Note: the $box operator only supports legacy coordinate pairs and 2d |
||
| 643 | * indexes. This cannot be used with 2dsphere indexes and GeoJSON shapes. |
||
| 644 | * |
||
| 645 | * @see Expr::geoWithinBox() |
||
| 646 | * @see http://docs.mongodb.org/manual/reference/operator/box/ |
||
| 647 | * @param float $x1 |
||
| 648 | * @param float $y1 |
||
| 649 | * @param float $x2 |
||
| 650 | * @param float $y2 |
||
| 651 | * @return $this |
||
| 652 | */ |
||
| 653 | 1 | public function geoWithinBox($x1, $y1, $x2, $y2) |
|
| 658 | |||
| 659 | /** |
||
| 660 | * Add $geoWithin criteria with a $center shape to the query. |
||
| 661 | * |
||
| 662 | * Note: the $center operator only supports legacy coordinate pairs and 2d |
||
| 663 | * indexes. This cannot be used with 2dsphere indexes and GeoJSON shapes. |
||
| 664 | * |
||
| 665 | * @see Expr::geoWithinCenter() |
||
| 666 | * @see http://docs.mongodb.org/manual/reference/operator/center/ |
||
| 667 | * @param float $x |
||
| 668 | * @param float $y |
||
| 669 | * @param float $radius |
||
| 670 | * @return $this |
||
| 671 | */ |
||
| 672 | 1 | public function geoWithinCenter($x, $y, $radius) |
|
| 677 | |||
| 678 | /** |
||
| 679 | * Add $geoWithin criteria with a $centerSphere shape to the query. |
||
| 680 | * |
||
| 681 | * Note: the $centerSphere operator supports both 2d and 2dsphere indexes. |
||
| 682 | * |
||
| 683 | * @see Expr::geoWithinCenterSphere() |
||
| 684 | * @see http://docs.mongodb.org/manual/reference/operator/centerSphere/ |
||
| 685 | * @param float $x |
||
| 686 | * @param float $y |
||
| 687 | * @param float $radius |
||
| 688 | * @return $this |
||
| 689 | */ |
||
| 690 | 1 | public function geoWithinCenterSphere($x, $y, $radius) |
|
| 695 | |||
| 696 | /** |
||
| 697 | * Add $geoWithin criteria with a $polygon shape to the query. |
||
| 698 | * |
||
| 699 | * Point coordinates are in x, y order (easting, northing for projected |
||
| 700 | * coordinates, longitude, latitude for geographic coordinates). |
||
| 701 | * |
||
| 702 | * The last point coordinate is implicitly connected with the first. |
||
| 703 | * |
||
| 704 | * Note: the $polygon operator only supports legacy coordinate pairs and 2d |
||
| 705 | * indexes. This cannot be used with 2dsphere indexes and GeoJSON shapes. |
||
| 706 | * |
||
| 707 | * @see Expr::geoWithinPolygon() |
||
| 708 | * @see http://docs.mongodb.org/manual/reference/operator/polygon/ |
||
| 709 | * @param array $point,... Three or more point coordinate tuples |
||
| 710 | * @return $this |
||
| 711 | */ |
||
| 712 | 1 | public function geoWithinPolygon(/* array($x1, $y1), ... */) |
|
| 717 | |||
| 718 | /** |
||
| 719 | * Return the expression's "new object". |
||
| 720 | * |
||
| 721 | * @see Expr::getNewObj() |
||
| 722 | * @return array |
||
| 723 | */ |
||
| 724 | 13 | public function getNewObj() |
|
| 728 | |||
| 729 | /** |
||
| 730 | * Gets the Query executable. |
||
| 731 | * |
||
| 732 | * @param array $options |
||
| 733 | * @return Query $query |
||
| 734 | */ |
||
| 735 | 150 | public function getQuery(array $options = array()) |
|
| 796 | |||
| 797 | /** |
||
| 798 | * Return the expression's query criteria. |
||
| 799 | * |
||
| 800 | * @see Expr::getQuery() |
||
| 801 | * @return array |
||
| 802 | */ |
||
| 803 | 33 | public function getQueryArray() |
|
| 807 | |||
| 808 | /** |
||
| 809 | * Get the type of this query. |
||
| 810 | * |
||
| 811 | * @return integer $type |
||
| 812 | */ |
||
| 813 | 2 | public function getType() |
|
| 817 | |||
| 818 | /** |
||
| 819 | * Specify $gt criteria for the current field. |
||
| 820 | * |
||
| 821 | * @see Expr::gt() |
||
| 822 | * @see http://docs.mongodb.org/manual/reference/operator/gt/ |
||
| 823 | * @param mixed $value |
||
| 824 | * @return $this |
||
| 825 | */ |
||
| 826 | 2 | public function gt($value) |
|
| 831 | |||
| 832 | /** |
||
| 833 | * Specify $gte criteria for the current field. |
||
| 834 | * |
||
| 835 | * @see Expr::gte() |
||
| 836 | * @see http://docs.mongodb.org/manual/reference/operator/gte/ |
||
| 837 | * @param mixed $value |
||
| 838 | * @return $this |
||
| 839 | */ |
||
| 840 | 2 | public function gte($value) |
|
| 845 | |||
| 846 | /** |
||
| 847 | * Set the index hint for the query. |
||
| 848 | * |
||
| 849 | * @param array|string $index |
||
| 850 | * @return $this |
||
| 851 | */ |
||
| 852 | public function hint($index) |
||
| 857 | |||
| 858 | /** |
||
| 859 | * @param bool $bool |
||
| 860 | * @return $this |
||
| 861 | */ |
||
| 862 | 17 | public function hydrate($bool = true) |
|
| 867 | |||
| 868 | /** |
||
| 869 | * Set the immortal cursor flag. |
||
| 870 | * |
||
| 871 | * @param boolean $bool |
||
| 872 | * @return $this |
||
| 873 | */ |
||
| 874 | public function immortal($bool = true) |
||
| 879 | |||
| 880 | /** |
||
| 881 | * Specify $in criteria for the current field. |
||
| 882 | * |
||
| 883 | * @see Expr::in() |
||
| 884 | * @see http://docs.mongodb.org/manual/reference/operator/in/ |
||
| 885 | * @param array $values |
||
| 886 | * @return $this |
||
| 887 | */ |
||
| 888 | 24 | public function in(array $values) |
|
| 893 | |||
| 894 | /** |
||
| 895 | * Increment the current field. |
||
| 896 | * |
||
| 897 | * If the field does not exist, it will be set to this value. |
||
| 898 | * |
||
| 899 | * @see Expr::inc() |
||
| 900 | * @see http://docs.mongodb.org/manual/reference/operator/inc/ |
||
| 901 | * @param float|integer $value |
||
| 902 | * @return $this |
||
| 903 | */ |
||
| 904 | 6 | public function inc($value) |
|
| 909 | |||
| 910 | /** |
||
| 911 | * @param object $document |
||
| 912 | * @return $this |
||
| 913 | */ |
||
| 914 | 6 | public function includesReferenceTo($document) |
|
| 919 | |||
| 920 | /** |
||
| 921 | * @param string $documentName |
||
| 922 | * @return $this |
||
| 923 | */ |
||
| 924 | 1 | public function insert($documentName = null) |
|
| 931 | |||
| 932 | /** |
||
| 933 | * Set the $language option for $text criteria. |
||
| 934 | * |
||
| 935 | * This method must be called after text(). |
||
| 936 | * |
||
| 937 | * @see Expr::language() |
||
| 938 | * @see http://docs.mongodb.org/manual/reference/operator/text/ |
||
| 939 | * @param string $language |
||
| 940 | * @return $this |
||
| 941 | */ |
||
| 942 | 1 | public function language($language) |
|
| 947 | |||
| 948 | /** |
||
| 949 | * Set the limit for the query. |
||
| 950 | * |
||
| 951 | * This is only relevant for find queries and geoNear and mapReduce |
||
| 952 | * commands. |
||
| 953 | * |
||
| 954 | * @see Query::prepareCursor() |
||
| 955 | * @param integer $limit |
||
| 956 | * @return $this |
||
| 957 | */ |
||
| 958 | 2 | public function limit($limit) |
|
| 963 | |||
| 964 | /** |
||
| 965 | * Specify $lt criteria for the current field. |
||
| 966 | * |
||
| 967 | * @see Expr::lte() |
||
| 968 | * @see http://docs.mongodb.org/manual/reference/operator/lte/ |
||
| 969 | * @param mixed $value |
||
| 970 | * @return $this |
||
| 971 | */ |
||
| 972 | public function lt($value) |
||
| 977 | |||
| 978 | /** |
||
| 979 | * Specify $lte criteria for the current field. |
||
| 980 | * |
||
| 981 | * @see Expr::lte() |
||
| 982 | * @see http://docs.mongodb.org/manual/reference/operator/lte/ |
||
| 983 | * @param mixed $value |
||
| 984 | * @return $this |
||
| 985 | */ |
||
| 986 | public function lte($value) |
||
| 991 | |||
| 992 | /** |
||
| 993 | * Change the query type to a mapReduce command. |
||
| 994 | * |
||
| 995 | * The "reduce" option is not specified when calling this method; it must |
||
| 996 | * be set with the {@link Builder::reduce()} method. |
||
| 997 | * |
||
| 998 | * The "out" option defaults to inline, like {@link Builder::mapReduce()}. |
||
| 999 | * |
||
| 1000 | * @see http://docs.mongodb.org/manual/reference/command/mapReduce/ |
||
| 1001 | * @param string|\MongoCode $map |
||
| 1002 | * @return $this |
||
| 1003 | */ |
||
| 1004 | 1 | public function map($map) |
|
| 1015 | |||
| 1016 | /** |
||
| 1017 | * Change the query type to a mapReduce command. |
||
| 1018 | * |
||
| 1019 | * @see http://docs.mongodb.org/manual/reference/command/mapReduce/ |
||
| 1020 | * @param string|\MongoCode $map |
||
| 1021 | * @param string|\MongoCode $reduce |
||
| 1022 | * @param array|string $out |
||
| 1023 | * @param array $options |
||
| 1024 | * @return $this |
||
| 1025 | */ |
||
| 1026 | 1 | public function mapReduce($map, $reduce, $out = ['inline' => true], array $options = []) |
|
| 1037 | |||
| 1038 | /** |
||
| 1039 | * Set additional options for a mapReduce command. |
||
| 1040 | * |
||
| 1041 | * @param array $options |
||
| 1042 | * @return $this |
||
| 1043 | * @throws \BadMethodCallException if the query is not a mapReduce command |
||
| 1044 | */ |
||
| 1045 | 1 | View Code Duplication | public function mapReduceOptions(array $options) |
| 1054 | |||
| 1055 | /** |
||
| 1056 | * Updates the value of the field to a specified value if the specified value is greater than the current value of the field. |
||
| 1057 | * |
||
| 1058 | * @see Expr::max() |
||
| 1059 | * @see http://docs.mongodb.org/manual/reference/operator/update/max/ |
||
| 1060 | * @param mixed $value |
||
| 1061 | * @return $this |
||
| 1062 | */ |
||
| 1063 | 1 | public function max($value) |
|
| 1068 | |||
| 1069 | /** |
||
| 1070 | * Specifies a cumulative time limit in milliseconds for processing operations on a cursor. |
||
| 1071 | * |
||
| 1072 | * @param int $ms |
||
| 1073 | * @return $this |
||
| 1074 | */ |
||
| 1075 | public function maxTimeMS($ms) |
||
| 1080 | |||
| 1081 | /** |
||
| 1082 | * Updates the value of the field to a specified value if the specified value is less than the current value of the field. |
||
| 1083 | * |
||
| 1084 | * @see Expr::min() |
||
| 1085 | * @see http://docs.mongodb.org/manual/reference/operator/update/min/ |
||
| 1086 | * @param mixed $value |
||
| 1087 | * @return $this |
||
| 1088 | */ |
||
| 1089 | 1 | public function min($value) |
|
| 1094 | |||
| 1095 | /** |
||
| 1096 | * Specify $mod criteria for the current field. |
||
| 1097 | * |
||
| 1098 | * @see Expr::mod() |
||
| 1099 | * @see http://docs.mongodb.org/manual/reference/operator/mod/ |
||
| 1100 | * @param float|integer $divisor |
||
| 1101 | * @param float|integer $remainder |
||
| 1102 | * @return $this |
||
| 1103 | */ |
||
| 1104 | 1 | public function mod($divisor, $remainder = 0) |
|
| 1109 | |||
| 1110 | /** |
||
| 1111 | * Multiply the current field. |
||
| 1112 | * |
||
| 1113 | * If the field does not exist, it will be set to 0. |
||
| 1114 | * |
||
| 1115 | * @see Expr::mul() |
||
| 1116 | * @see http://docs.mongodb.org/manual/reference/operator/mul/ |
||
| 1117 | * @param float|integer $value |
||
| 1118 | * @return $this |
||
| 1119 | */ |
||
| 1120 | 1 | public function mul($value) |
|
| 1125 | |||
| 1126 | /** |
||
| 1127 | * Set the "multiple" option for an update query. |
||
| 1128 | * |
||
| 1129 | * @param boolean $bool |
||
| 1130 | * @return $this |
||
| 1131 | * |
||
| 1132 | * @deprecated Deprecated in version 1.4 - use updateOne or updateMany instead |
||
| 1133 | */ |
||
| 1134 | public function multiple($bool = true) |
||
| 1139 | |||
| 1140 | /** |
||
| 1141 | * Add $near criteria to the query. |
||
| 1142 | * |
||
| 1143 | * A GeoJSON point may be provided as the first and only argument for |
||
| 1144 | * 2dsphere queries. This single parameter may be a GeoJSON point object or |
||
| 1145 | * an array corresponding to the point's JSON representation. |
||
| 1146 | * |
||
| 1147 | * @see Expr::near() |
||
| 1148 | * @see http://docs.mongodb.org/manual/reference/operator/near/ |
||
| 1149 | * @param float|array|Point $x |
||
| 1150 | * @param float $y |
||
| 1151 | * @return $this |
||
| 1152 | */ |
||
| 1153 | 1 | public function near($x, $y = null) |
|
| 1158 | |||
| 1159 | /** |
||
| 1160 | * Add $nearSphere criteria to the query. |
||
| 1161 | * |
||
| 1162 | * A GeoJSON point may be provided as the first and only argument for |
||
| 1163 | * 2dsphere queries. This single parameter may be a GeoJSON point object or |
||
| 1164 | * an array corresponding to the point's JSON representation. |
||
| 1165 | * |
||
| 1166 | * @see Expr::nearSphere() |
||
| 1167 | * @see http://docs.mongodb.org/manual/reference/operator/nearSphere/ |
||
| 1168 | * @param float|array|Point $x |
||
| 1169 | * @param float $y |
||
| 1170 | * @return $this |
||
| 1171 | */ |
||
| 1172 | 1 | public function nearSphere($x, $y = null) |
|
| 1177 | |||
| 1178 | /** |
||
| 1179 | * Negates an expression for the current field. |
||
| 1180 | * |
||
| 1181 | * You can create a new expression using the {@link Builder::expr()} method. |
||
| 1182 | * |
||
| 1183 | * @see Expr::not() |
||
| 1184 | * @see http://docs.mongodb.org/manual/reference/operator/not/ |
||
| 1185 | * @param array|Expr $expression |
||
| 1186 | * @return $this |
||
| 1187 | */ |
||
| 1188 | 3 | public function not($expression) |
|
| 1193 | |||
| 1194 | /** |
||
| 1195 | * Specify $ne criteria for the current field. |
||
| 1196 | * |
||
| 1197 | * @see Expr::notEqual() |
||
| 1198 | * @see http://docs.mongodb.org/manual/reference/operator/ne/ |
||
| 1199 | * @param mixed $value |
||
| 1200 | * @return $this |
||
| 1201 | */ |
||
| 1202 | 4 | public function notEqual($value) |
|
| 1207 | |||
| 1208 | /** |
||
| 1209 | * Specify $nin criteria for the current field. |
||
| 1210 | * |
||
| 1211 | * @see Expr::notIn() |
||
| 1212 | * @see http://docs.mongodb.org/manual/reference/operator/nin/ |
||
| 1213 | * @param array $values |
||
| 1214 | * @return $this |
||
| 1215 | */ |
||
| 1216 | 4 | public function notIn(array $values) |
|
| 1221 | |||
| 1222 | /** |
||
| 1223 | * Set the "out" option for a mapReduce command. |
||
| 1224 | * |
||
| 1225 | * @param array|string $out |
||
| 1226 | * @return $this |
||
| 1227 | * @throws \BadMethodCallException if the query is not a mapReduce command |
||
| 1228 | */ |
||
| 1229 | 1 | View Code Duplication | public function out($out) |
| 1238 | |||
| 1239 | /** |
||
| 1240 | * Remove the first element from the current array field. |
||
| 1241 | * |
||
| 1242 | * @see Expr::popFirst() |
||
| 1243 | * @see http://docs.mongodb.org/manual/reference/operator/pop/ |
||
| 1244 | * @return $this |
||
| 1245 | */ |
||
| 1246 | 2 | public function popFirst() |
|
| 1251 | |||
| 1252 | /** |
||
| 1253 | * Remove the last element from the current array field. |
||
| 1254 | * |
||
| 1255 | * @see Expr::popLast() |
||
| 1256 | * @see http://docs.mongodb.org/manual/reference/operator/pop/ |
||
| 1257 | * @return $this |
||
| 1258 | */ |
||
| 1259 | 1 | public function popLast() |
|
| 1264 | |||
| 1265 | /** |
||
| 1266 | * Use a primer to eagerly load all references in the current field. |
||
| 1267 | * |
||
| 1268 | * If $primer is true or a callable is provided, referenced documents for |
||
| 1269 | * this field will loaded into UnitOfWork immediately after the query is |
||
| 1270 | * executed. This will avoid multiple queries due to lazy initialization of |
||
| 1271 | * Proxy objects. |
||
| 1272 | * |
||
| 1273 | * If $primer is false, no priming will take place. That is also the default |
||
| 1274 | * behavior. |
||
| 1275 | * |
||
| 1276 | * If a custom callable is used, its signature should conform to the default |
||
| 1277 | * Closure defined in {@link ReferencePrimer::__construct()}. |
||
| 1278 | * |
||
| 1279 | * @param boolean|callable $primer |
||
| 1280 | * @return $this |
||
| 1281 | * @throws \InvalidArgumentException If $primer is not boolean or callable |
||
| 1282 | */ |
||
| 1283 | 25 | public function prime($primer = true) |
|
| 1302 | |||
| 1303 | /** |
||
| 1304 | * Remove all elements matching the given value or expression from the |
||
| 1305 | * current array field. |
||
| 1306 | * |
||
| 1307 | * @see Expr::pull() |
||
| 1308 | * @see http://docs.mongodb.org/manual/reference/operator/pull/ |
||
| 1309 | * @param mixed|Expr $valueOrExpression |
||
| 1310 | * @return $this |
||
| 1311 | */ |
||
| 1312 | 1 | public function pull($valueOrExpression) |
|
| 1317 | |||
| 1318 | /** |
||
| 1319 | * Remove all elements matching any of the given values from the current |
||
| 1320 | * array field. |
||
| 1321 | * |
||
| 1322 | * @see Expr::pullAll() |
||
| 1323 | * @see http://docs.mongodb.org/manual/reference/operator/pullAll/ |
||
| 1324 | * @param array $values |
||
| 1325 | * @return $this |
||
| 1326 | */ |
||
| 1327 | 1 | public function pullAll(array $values) |
|
| 1332 | |||
| 1333 | /** |
||
| 1334 | * Append one or more values to the current array field. |
||
| 1335 | * |
||
| 1336 | * If the field does not exist, it will be set to an array containing the |
||
| 1337 | * value(s) in the argument. If the field is not an array, the query |
||
| 1338 | * will yield an error. |
||
| 1339 | * |
||
| 1340 | * Multiple values may be specified by providing an Expr object and using |
||
| 1341 | * {@link Expr::each()}. {@link Expr::slice()} and {@link Expr::sort()} may |
||
| 1342 | * also be used to limit and order array elements, respectively. |
||
| 1343 | * |
||
| 1344 | * @see Expr::push() |
||
| 1345 | * @see http://docs.mongodb.org/manual/reference/operator/push/ |
||
| 1346 | * @see http://docs.mongodb.org/manual/reference/operator/each/ |
||
| 1347 | * @see http://docs.mongodb.org/manual/reference/operator/slice/ |
||
| 1348 | * @see http://docs.mongodb.org/manual/reference/operator/sort/ |
||
| 1349 | * @param mixed|Expr $valueOrExpression |
||
| 1350 | * @return $this |
||
| 1351 | */ |
||
| 1352 | 6 | public function push($valueOrExpression) |
|
| 1357 | |||
| 1358 | /** |
||
| 1359 | * Append multiple values to the current array field. |
||
| 1360 | * |
||
| 1361 | * If the field does not exist, it will be set to an array containing the |
||
| 1362 | * values in the argument. If the field is not an array, the query will |
||
| 1363 | * yield an error. |
||
| 1364 | * |
||
| 1365 | * This operator is deprecated in MongoDB 2.4. {@link Builder::push()} and |
||
| 1366 | * {@link Expr::each()} should be used in its place. |
||
| 1367 | * |
||
| 1368 | * @see Expr::pushAll() |
||
| 1369 | * @see http://docs.mongodb.org/manual/reference/operator/pushAll/ |
||
| 1370 | * @param array $values |
||
| 1371 | * @return $this |
||
| 1372 | */ |
||
| 1373 | 1 | public function pushAll(array $values) |
|
| 1378 | |||
| 1379 | /** |
||
| 1380 | * Specify $gte and $lt criteria for the current field. |
||
| 1381 | * |
||
| 1382 | * This method is shorthand for specifying $gte criteria on the lower bound |
||
| 1383 | * and $lt criteria on the upper bound. The upper bound is not inclusive. |
||
| 1384 | * |
||
| 1385 | * @see Expr::range() |
||
| 1386 | * @param mixed $start |
||
| 1387 | * @param mixed $end |
||
| 1388 | * @return $this |
||
| 1389 | */ |
||
| 1390 | 3 | public function range($start, $end) |
|
| 1395 | |||
| 1396 | /** |
||
| 1397 | * @param bool $bool |
||
| 1398 | * @return $this |
||
| 1399 | */ |
||
| 1400 | 2 | public function readOnly($bool = true) |
|
| 1405 | |||
| 1406 | /** |
||
| 1407 | * Set the "reduce" option for a mapReduce or group command. |
||
| 1408 | * |
||
| 1409 | * @param string|\MongoCode $reduce |
||
| 1410 | * @return $this |
||
| 1411 | * @throws \BadMethodCallException if the query is not a mapReduce or group command |
||
| 1412 | */ |
||
| 1413 | 2 | View Code Duplication | public function reduce($reduce) |
| 1414 | { |
||
| 1415 | 2 | switch ($this->query['type']) { |
|
| 1416 | case Query::TYPE_MAP_REDUCE: |
||
| 1417 | 1 | $this->query['mapReduce']['reduce'] = $reduce; |
|
| 1418 | 1 | break; |
|
| 1419 | |||
| 1420 | case Query::TYPE_GROUP: |
||
| 1421 | $this->query['group']['reduce'] = $reduce; |
||
| 1422 | break; |
||
| 1423 | |||
| 1424 | default: |
||
| 1425 | 1 | throw new \BadMethodCallException('mapReduce(), map() or group() must be called before reduce()'); |
|
| 1426 | } |
||
| 1427 | |||
| 1428 | 1 | return $this; |
|
| 1429 | } |
||
| 1430 | |||
| 1431 | /** |
||
| 1432 | * @param object $document |
||
| 1433 | * @return $this |
||
| 1434 | */ |
||
| 1435 | 10 | public function references($document) |
|
| 1440 | |||
| 1441 | /** |
||
| 1442 | * @param bool $bool |
||
| 1443 | * @return $this |
||
| 1444 | */ |
||
| 1445 | 5 | public function refresh($bool = true) |
|
| 1450 | |||
| 1451 | /** |
||
| 1452 | * @param string $documentName |
||
| 1453 | * @return $this |
||
| 1454 | */ |
||
| 1455 | 1 | public function remove($documentName = null) |
|
| 1462 | |||
| 1463 | /** |
||
| 1464 | * Rename the current field. |
||
| 1465 | * |
||
| 1466 | * @see Expr::rename() |
||
| 1467 | * @see http://docs.mongodb.org/manual/reference/operator/rename/ |
||
| 1468 | * @param string $name |
||
| 1469 | * @return $this |
||
| 1470 | */ |
||
| 1471 | public function rename($name) |
||
| 1476 | |||
| 1477 | /** |
||
| 1478 | * @param bool $bool |
||
| 1479 | * @return $this |
||
| 1480 | */ |
||
| 1481 | 4 | public function returnNew($bool = true) |
|
| 1488 | |||
| 1489 | /** |
||
| 1490 | * Set one or more fields to be included in the query projection. |
||
| 1491 | * |
||
| 1492 | * @param array|string $fieldName,... |
||
| 1493 | * @return $this |
||
| 1494 | */ |
||
| 1495 | 19 | View Code Duplication | public function select($fieldName = null) |
| 1509 | |||
| 1510 | /** |
||
| 1511 | * Select only matching embedded documents in an array field for the query |
||
| 1512 | * projection. |
||
| 1513 | * |
||
| 1514 | * @see http://docs.mongodb.org/manual/reference/projection/elemMatch/ |
||
| 1515 | * @param string $fieldName |
||
| 1516 | * @param array|Expr $expression |
||
| 1517 | * @return $this |
||
| 1518 | */ |
||
| 1519 | 2 | public function selectElemMatch($fieldName, $expression) |
|
| 1527 | |||
| 1528 | /** |
||
| 1529 | * Select a metadata field for the query projection. |
||
| 1530 | * |
||
| 1531 | * @see http://docs.mongodb.org/master/reference/operator/projection/meta/ |
||
| 1532 | * @param string $fieldName |
||
| 1533 | * @param string $metaDataKeyword |
||
| 1534 | * @return $this |
||
| 1535 | */ |
||
| 1536 | 2 | public function selectMeta($fieldName, $metaDataKeyword) |
|
| 1541 | |||
| 1542 | /** |
||
| 1543 | * Select a slice of an array field for the query projection. |
||
| 1544 | * |
||
| 1545 | * The $countOrSkip parameter has two very different meanings, depending on |
||
| 1546 | * whether or not $limit is provided. See the MongoDB documentation for more |
||
| 1547 | * information. |
||
| 1548 | * |
||
| 1549 | * @see http://docs.mongodb.org/manual/reference/projection/slice/ |
||
| 1550 | * @param string $fieldName |
||
| 1551 | * @param integer $countOrSkip Count parameter, or skip if limit is specified |
||
| 1552 | * @param integer $limit Limit parameter used in conjunction with skip |
||
| 1553 | * @return $this |
||
| 1554 | */ |
||
| 1555 | 3 | public function selectSlice($fieldName, $countOrSkip, $limit = null) |
|
| 1564 | |||
| 1565 | /** |
||
| 1566 | * Set the current field to a value. |
||
| 1567 | * |
||
| 1568 | * This is only relevant for insert, update, or findAndUpdate queries. For |
||
| 1569 | * update and findAndUpdate queries, the $atomic parameter will determine |
||
| 1570 | * whether or not a $set operator is used. |
||
| 1571 | * |
||
| 1572 | * @see Expr::set() |
||
| 1573 | * @see http://docs.mongodb.org/manual/reference/operator/set/ |
||
| 1574 | * @param mixed $value |
||
| 1575 | * @param boolean $atomic |
||
| 1576 | * @return $this |
||
| 1577 | */ |
||
| 1578 | 16 | public function set($value, $atomic = true) |
|
| 1583 | |||
| 1584 | /** |
||
| 1585 | * Set the expression's "new object". |
||
| 1586 | * |
||
| 1587 | * @see Expr::setNewObj() |
||
| 1588 | * @param array $newObj |
||
| 1589 | * @return $this |
||
| 1590 | */ |
||
| 1591 | public function setNewObj(array $newObj) |
||
| 1596 | |||
| 1597 | /** |
||
| 1598 | * Set the current field to the value if the document is inserted in an |
||
| 1599 | * upsert operation. |
||
| 1600 | * |
||
| 1601 | * If an update operation with upsert: true results in an insert of a |
||
| 1602 | * document, then $setOnInsert assigns the specified values to the fields in |
||
| 1603 | * the document. If the update operation does not result in an insert, |
||
| 1604 | * $setOnInsert does nothing. |
||
| 1605 | * |
||
| 1606 | * @see Expr::setOnInsert() |
||
| 1607 | * @see https://docs.mongodb.org/manual/reference/operator/update/setOnInsert/ |
||
| 1608 | * @param mixed $value |
||
| 1609 | * @return $this |
||
| 1610 | */ |
||
| 1611 | 2 | public function setOnInsert($value) |
|
| 1616 | |||
| 1617 | /** |
||
| 1618 | * Set the read preference for the query. |
||
| 1619 | * |
||
| 1620 | * This is only relevant for read-only queries and commands. |
||
| 1621 | * |
||
| 1622 | * @see http://docs.mongodb.org/manual/core/read-preference/ |
||
| 1623 | * @param ReadPreference $readPreference |
||
| 1624 | * @return $this |
||
| 1625 | */ |
||
| 1626 | 6 | public function setReadPreference(ReadPreference $readPreference) |
|
| 1631 | |||
| 1632 | /** |
||
| 1633 | * Set the expression's query criteria. |
||
| 1634 | * |
||
| 1635 | * @see Expr::setQuery() |
||
| 1636 | * @param array $query |
||
| 1637 | * @return $this |
||
| 1638 | */ |
||
| 1639 | 18 | public function setQueryArray(array $query) |
|
| 1644 | |||
| 1645 | /** |
||
| 1646 | * Specify $size criteria for the current field. |
||
| 1647 | * |
||
| 1648 | * @see Expr::size() |
||
| 1649 | * @see http://docs.mongodb.org/manual/reference/operator/size/ |
||
| 1650 | * @param integer $size |
||
| 1651 | * @return $this |
||
| 1652 | */ |
||
| 1653 | 1 | public function size($size) |
|
| 1658 | |||
| 1659 | /** |
||
| 1660 | * Set the skip for the query cursor. |
||
| 1661 | * |
||
| 1662 | * This is only relevant for find queries, or mapReduce queries that store |
||
| 1663 | * results in an output collecton and return a cursor. |
||
| 1664 | * |
||
| 1665 | * @see Query::prepareCursor() |
||
| 1666 | * @param integer $skip |
||
| 1667 | * @return $this |
||
| 1668 | */ |
||
| 1669 | public function skip($skip) |
||
| 1674 | |||
| 1675 | /** |
||
| 1676 | * Set the snapshot cursor flag. |
||
| 1677 | * |
||
| 1678 | * @param boolean $bool |
||
| 1679 | * @return $this |
||
| 1680 | */ |
||
| 1681 | public function snapshot($bool = true) |
||
| 1686 | |||
| 1687 | /** |
||
| 1688 | * Set one or more field/order pairs on which to sort the query. |
||
| 1689 | * |
||
| 1690 | * If sorting by multiple fields, the first argument should be an array of |
||
| 1691 | * field name (key) and order (value) pairs. |
||
| 1692 | * |
||
| 1693 | * @param array|string $fieldName Field name or array of field/order pairs |
||
| 1694 | * @param int|string $order Field order (if one field is specified) |
||
| 1695 | * @return $this |
||
| 1696 | */ |
||
| 1697 | 31 | public function sort($fieldName, $order = 1) |
|
| 1714 | |||
| 1715 | /** |
||
| 1716 | * Specify a projected metadata field on which to sort the query. |
||
| 1717 | * |
||
| 1718 | * Sort order is not configurable for metadata fields. Sorting by a metadata |
||
| 1719 | * field requires the same field and $meta expression to exist in the |
||
| 1720 | * projection document. This method will call {@link Builder::selectMeta()} |
||
| 1721 | * if the field is not already set in the projection. |
||
| 1722 | * |
||
| 1723 | * @see http://docs.mongodb.org/master/reference/operator/projection/meta/#sort |
||
| 1724 | * @param string $fieldName Field name of the projected metadata |
||
| 1725 | * @param string $metaDataKeyword |
||
| 1726 | * @return $this |
||
| 1727 | */ |
||
| 1728 | 2 | public function sortMeta($fieldName, $metaDataKeyword) |
|
| 1742 | |||
| 1743 | /** |
||
| 1744 | * Specify $text criteria for the current field. |
||
| 1745 | * |
||
| 1746 | * The $language option may be set with {@link Builder::language()}. |
||
| 1747 | * |
||
| 1748 | * @see Expr::text() |
||
| 1749 | * @see http://docs.mongodb.org/master/reference/operator/query/text/ |
||
| 1750 | * @param string $search |
||
| 1751 | * @return $this |
||
| 1752 | */ |
||
| 1753 | 1 | public function text($search) |
|
| 1758 | |||
| 1759 | /** |
||
| 1760 | * Specify $type criteria for the current field. |
||
| 1761 | * |
||
| 1762 | * @see Expr::type() |
||
| 1763 | * @see http://docs.mongodb.org/manual/reference/operator/type/ |
||
| 1764 | * @param integer $type |
||
| 1765 | * @return $this |
||
| 1766 | */ |
||
| 1767 | 2 | public function type($type) |
|
| 1772 | |||
| 1773 | /** |
||
| 1774 | * Unset the current field. |
||
| 1775 | * |
||
| 1776 | * The field will be removed from the document (not set to null). |
||
| 1777 | * |
||
| 1778 | * @see Expr::unsetField() |
||
| 1779 | * @see http://docs.mongodb.org/manual/reference/operator/unset/ |
||
| 1780 | * @return $this |
||
| 1781 | */ |
||
| 1782 | 4 | public function unsetField() |
|
| 1787 | |||
| 1788 | /** |
||
| 1789 | * @param string $documentName |
||
| 1790 | * @return $this |
||
| 1791 | */ |
||
| 1792 | 21 | View Code Duplication | public function updateOne($documentName = null) |
| 1800 | |||
| 1801 | /** |
||
| 1802 | * @param string $documentName |
||
| 1803 | * @return $this |
||
| 1804 | */ |
||
| 1805 | 3 | View Code Duplication | public function updateMany($documentName = null) |
| 1813 | |||
| 1814 | /** |
||
| 1815 | * Set the "upsert" option for an update or findAndUpdate query. |
||
| 1816 | * |
||
| 1817 | * @param boolean $bool |
||
| 1818 | * @return $this |
||
| 1819 | */ |
||
| 1820 | 7 | public function upsert($bool = true) |
|
| 1825 | |||
| 1826 | /** |
||
| 1827 | * Specify a JavaScript expression to use for matching documents. |
||
| 1828 | * |
||
| 1829 | * @see Expr::where() |
||
| 1830 | * @see http://docs.mongodb.org/manual/reference/operator/where/ |
||
| 1831 | * @param string|\MongoCode $javascript |
||
| 1832 | * @return $this |
||
| 1833 | */ |
||
| 1834 | 3 | public function where($javascript) |
|
| 1839 | |||
| 1840 | /** |
||
| 1841 | * Add $within criteria with a $box shape to the query. |
||
| 1842 | * |
||
| 1843 | * @deprecated 1.1 MongoDB 2.4 deprecated $within in favor of $geoWithin |
||
| 1844 | * @see Builder::geoWithinBox() |
||
| 1845 | * @see Expr::withinBox() |
||
| 1846 | * @see http://docs.mongodb.org/manual/reference/operator/box/ |
||
| 1847 | * @param float $x1 |
||
| 1848 | * @param float $y1 |
||
| 1849 | * @param float $x2 |
||
| 1850 | * @param float $y2 |
||
| 1851 | * @return $this |
||
| 1852 | */ |
||
| 1853 | 1 | public function withinBox($x1, $y1, $x2, $y2) |
|
| 1858 | |||
| 1859 | /** |
||
| 1860 | * Add $within criteria with a $center shape to the query. |
||
| 1861 | * |
||
| 1862 | * @deprecated 1.1 MongoDB 2.4 deprecated $within in favor of $geoWithin |
||
| 1863 | * @see Builder::geoWithinCenter() |
||
| 1864 | * @see Expr::withinCenter() |
||
| 1865 | * @see http://docs.mongodb.org/manual/reference/operator/center/ |
||
| 1866 | * @param float $x |
||
| 1867 | * @param float $y |
||
| 1868 | * @param float $radius |
||
| 1869 | * @return $this |
||
| 1870 | */ |
||
| 1871 | 1 | public function withinCenter($x, $y, $radius) |
|
| 1876 | |||
| 1877 | /** |
||
| 1878 | * Add $within criteria with a $centerSphere shape to the query. |
||
| 1879 | * |
||
| 1880 | * @deprecated 1.1 MongoDB 2.4 deprecated $within in favor of $geoWithin |
||
| 1881 | * @see Builder::geoWithinCenterSphere() |
||
| 1882 | * @see Expr::withinCenterSphere() |
||
| 1883 | * @see http://docs.mongodb.org/manual/reference/operator/centerSphere/ |
||
| 1884 | * @param float $x |
||
| 1885 | * @param float $y |
||
| 1886 | * @param float $radius |
||
| 1887 | * @return $this |
||
| 1888 | */ |
||
| 1889 | 1 | public function withinCenterSphere($x, $y, $radius) |
|
| 1894 | |||
| 1895 | /** |
||
| 1896 | * Add $within criteria with a $polygon shape to the query. |
||
| 1897 | * |
||
| 1898 | * Point coordinates are in x, y order (easting, northing for projected |
||
| 1899 | * coordinates, longitude, latitude for geographic coordinates). |
||
| 1900 | * |
||
| 1901 | * The last point coordinate is implicitly connected with the first. |
||
| 1902 | * |
||
| 1903 | * @deprecated 1.1 MongoDB 2.4 deprecated $within in favor of $geoWithin |
||
| 1904 | * @see Builder::geoWithinPolygon() |
||
| 1905 | * @see Expr::withinPolygon() |
||
| 1906 | * @see http://docs.mongodb.org/manual/reference/operator/polygon/ |
||
| 1907 | * @param array $point,... Three or more point coordinate tuples |
||
| 1908 | * @return $this |
||
| 1909 | */ |
||
| 1910 | 1 | public function withinPolygon(/* array($x1, $y1), array($x2, $y2), ... */) |
|
| 1915 | |||
| 1916 | /** |
||
| 1917 | * Get Discriminator Values |
||
| 1918 | * |
||
| 1919 | * @param \Traversable $classNames |
||
| 1920 | * @return array an array of discriminatorValues (mixed type) |
||
| 1921 | * @throws \InvalidArgumentException if the number of found collections > 1 |
||
| 1922 | */ |
||
| 1923 | 2 | private function getDiscriminatorValues($classNames) |
|
| 1938 | |||
| 1939 | /** |
||
| 1940 | * @param string[]|string $documentName an array of document names or just one. |
||
| 1941 | */ |
||
| 1942 | 290 | private function setDocumentName($documentName) |
|
| 1968 | } |
||
| 1969 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.