Skip to content

Commit aebbc15

Browse files
committed
Split chained calls when inheriting options
1 parent 2492235 commit aebbc15

File tree

1 file changed

+32
-48
lines changed

1 file changed

+32
-48
lines changed

src/Collection.php

Lines changed: 32 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,8 @@ public function aggregate(array $pipeline, array $options = [])
258258
*/
259259
public function bulkWrite(array $operations, array $options = [])
260260
{
261-
$options = $this->inheritWriteOptions(
262-
$this->inheritCodec($options),
263-
);
261+
$options = $this->inheritWriteOptions($options);
262+
$options = $this->inheritCodec($options);
264263

265264
$operation = new BulkWrite($this->databaseName, $this->collectionName, $operations, $options);
266265

@@ -426,9 +425,8 @@ public function deleteOne($filter, array $options = [])
426425
*/
427426
public function distinct(string $fieldName, $filter = [], array $options = [])
428427
{
429-
$options = $this->inheritReadOptions(
430-
$this->inheritTypeMap($options),
431-
);
428+
$options = $this->inheritReadOptions($options);
429+
$options = $this->inheritTypeMap($options);
432430

433431
$operation = new Distinct($this->databaseName, $this->collectionName, $fieldName, $filter, $options);
434432

@@ -449,9 +447,8 @@ public function drop(array $options = [])
449447
{
450448
$server = select_server($this->manager, $options);
451449

452-
$options = $this->inheritWriteOptions(
453-
$this->inheritTypeMap($options),
454-
);
450+
$options = $this->inheritWriteOptions($options);
451+
$options = $this->inheritTypeMap($options);
455452

456453
if (! isset($options['encryptedFields'])) {
457454
$options['encryptedFields'] = get_encrypted_fields_from_driver($this->databaseName, $this->collectionName, $this->manager)
@@ -484,9 +481,8 @@ public function dropIndex($indexName, array $options = [])
484481
throw new InvalidArgumentException('dropIndexes() must be used to drop multiple indexes');
485482
}
486483

487-
$options = $this->inheritWriteOptions(
488-
$this->inheritTypeMap($options),
489-
);
484+
$options = $this->inheritWriteOptions($options);
485+
$options = $this->inheritTypeMap($options);
490486

491487
$operation = new DropIndexes($this->databaseName, $this->collectionName, $indexName, $options);
492488

@@ -505,9 +501,8 @@ public function dropIndex($indexName, array $options = [])
505501
*/
506502
public function dropIndexes(array $options = [])
507503
{
508-
$options = $this->inheritWriteOptions(
509-
$this->inheritTypeMap($options),
510-
);
504+
$options = $this->inheritWriteOptions($options);
505+
$options = $this->inheritTypeMap($options);
511506

512507
$operation = new DropIndexes($this->databaseName, $this->collectionName, '*', $options);
513508

@@ -573,9 +568,8 @@ public function explain(Explainable $explainable, array $options = [])
573568
*/
574569
public function find($filter = [], array $options = [])
575570
{
576-
$options = $this->inheritReadOptions(
577-
$this->inheritCodecOrTypeMap($options),
578-
);
571+
$options = $this->inheritReadOptions($options);
572+
$options = $this->inheritCodecOrTypeMap($options);
579573

580574
$operation = new Find($this->databaseName, $this->collectionName, $filter, $options);
581575

@@ -596,9 +590,8 @@ public function find($filter = [], array $options = [])
596590
*/
597591
public function findOne($filter = [], array $options = [])
598592
{
599-
$options = $this->inheritReadOptions(
600-
$this->inheritCodecOrTypeMap($options),
601-
);
593+
$options = $this->inheritReadOptions($options);
594+
$options = $this->inheritCodecOrTypeMap($options);
602595

603596
$operation = new FindOne($this->databaseName, $this->collectionName, $filter, $options);
604597

@@ -622,9 +615,8 @@ public function findOne($filter = [], array $options = [])
622615
*/
623616
public function findOneAndDelete($filter, array $options = [])
624617
{
625-
$options = $this->inheritWriteOptions(
626-
$this->inheritCodecOrTypeMap($options),
627-
);
618+
$options = $this->inheritWriteOptions($options);
619+
$options = $this->inheritCodecOrTypeMap($options);
628620

629621
$operation = new FindOneAndDelete($this->databaseName, $this->collectionName, $filter, $options);
630622

@@ -653,9 +645,8 @@ public function findOneAndDelete($filter, array $options = [])
653645
*/
654646
public function findOneAndReplace($filter, $replacement, array $options = [])
655647
{
656-
$options = $this->inheritWriteOptions(
657-
$this->inheritCodecOrTypeMap($options),
658-
);
648+
$options = $this->inheritWriteOptions($options);
649+
$options = $this->inheritCodecOrTypeMap($options);
659650

660651
$operation = new FindOneAndReplace($this->databaseName, $this->collectionName, $filter, $replacement, $options);
661652

@@ -684,9 +675,8 @@ public function findOneAndReplace($filter, $replacement, array $options = [])
684675
*/
685676
public function findOneAndUpdate($filter, $update, array $options = [])
686677
{
687-
$options = $this->inheritWriteOptions(
688-
$this->inheritCodecOrTypeMap($options),
689-
);
678+
$options = $this->inheritWriteOptions($options);
679+
$options = $this->inheritCodecOrTypeMap($options);
690680

691681
$operation = new FindOneAndUpdate($this->databaseName, $this->collectionName, $filter, $update, $options);
692682

@@ -789,9 +779,8 @@ public function getWriteConcern()
789779
*/
790780
public function insertMany(array $documents, array $options = [])
791781
{
792-
$options = $this->inheritWriteOptions(
793-
$this->inheritCodec($options),
794-
);
782+
$options = $this->inheritWriteOptions($options);
783+
$options = $this->inheritCodec($options);
795784

796785
$operation = new InsertMany($this->databaseName, $this->collectionName, $documents, $options);
797786

@@ -811,9 +800,8 @@ public function insertMany(array $documents, array $options = [])
811800
*/
812801
public function insertOne($document, array $options = [])
813802
{
814-
$options = $this->inheritWriteOptions(
815-
$this->inheritCodec($options),
816-
);
803+
$options = $this->inheritWriteOptions($options);
804+
$options = $this->inheritCodec($options);
817805

818806
$operation = new InsertOne($this->databaseName, $this->collectionName, $document, $options);
819807

@@ -872,9 +860,8 @@ public function mapReduce(JavascriptInterface $map, JavascriptInterface $reduce,
872860
$options['readConcern'] = $this->readConcern;
873861
}
874862

875-
$options = $this->inheritWriteOptions(
876-
$this->inheritTypeMap($options),
877-
);
863+
$options = $this->inheritWriteOptions($options);
864+
$options = $this->inheritTypeMap($options);
878865

879866
$operation = new MapReduce($this->databaseName, $this->collectionName, $map, $reduce, $out, $options);
880867

@@ -899,9 +886,8 @@ public function rename(string $toCollectionName, ?string $toDatabaseName = null,
899886
$toDatabaseName = $this->databaseName;
900887
}
901888

902-
$options = $this->inheritWriteOptions(
903-
$this->inheritTypeMap($options),
904-
);
889+
$options = $this->inheritWriteOptions($options);
890+
$options = $this->inheritTypeMap($options);
905891

906892
$operation = new RenameCollection($this->databaseName, $this->collectionName, $toDatabaseName, $toCollectionName, $options);
907893

@@ -923,9 +909,8 @@ public function rename(string $toCollectionName, ?string $toDatabaseName = null,
923909
*/
924910
public function replaceOne($filter, $replacement, array $options = [])
925911
{
926-
$options = $this->inheritWriteOptions(
927-
$this->inheritCodec($options),
928-
);
912+
$options = $this->inheritWriteOptions($options);
913+
$options = $this->inheritCodec($options);
929914

930915
$operation = new ReplaceOne($this->databaseName, $this->collectionName, $filter, $replacement, $options);
931916

@@ -987,9 +972,8 @@ public function updateOne($filter, $update, array $options = [])
987972
*/
988973
public function watch(array $pipeline = [], array $options = [])
989974
{
990-
$options = $this->inheritReadOptions(
991-
$this->inheritCodecOrTypeMap($options),
992-
);
975+
$options = $this->inheritReadOptions($options);
976+
$options = $this->inheritCodecOrTypeMap($options);
993977

994978
$operation = new Watch($this->manager, $this->databaseName, $this->collectionName, $pipeline, $options);
995979

0 commit comments

Comments
 (0)