@@ -68,10 +68,6 @@ public function __construct($databaseName, $collectionName, $filter, $replacemen
6868 'upsert ' => false ,
6969 );
7070
71- if (isset ($ options ['maxTimeMS ' ]) && ! is_integer ($ options ['maxTimeMS ' ])) {
72- throw new InvalidArgumentTypeException ('"maxTimeMS" option ' , $ options ['maxTimeMS ' ], 'integer ' );
73- }
74-
7571 if (isset ($ options ['projection ' ]) && ! is_array ($ options ['projection ' ]) && ! is_object ($ options ['projection ' ])) {
7672 throw new InvalidArgumentTypeException ('"projection" option ' , $ options ['projection ' ], 'array or object ' );
7773 }
@@ -85,26 +81,21 @@ public function __construct($databaseName, $collectionName, $filter, $replacemen
8581 throw new InvalidArgumentException ('Invalid value for "returnDocument" option: ' . $ options ['returnDocument ' ]);
8682 }
8783
88- if (isset ($ options ['sort ' ]) && ! is_array ( $ options [ ' sort ' ]) && ! is_object ( $ options [ ' sort ' ])) {
89- throw new InvalidArgumentTypeException ( ' "sort" option ' , $ options ['sort ' ], ' array or object ' ) ;
84+ if (isset ($ options ['projection ' ])) {
85+ $ options ['fields ' ] = $ options [ ' projection ' ] ;
9086 }
9187
92- if ( ! is_bool ( $ options ['upsert ' ])) {
93- throw new InvalidArgumentTypeException ( ' "upsert" option ' , $ options [ ' upsert ' ], ' boolean ' );
94- }
88+ $ options [ ' new ' ] = $ options ['returnDocument ' ] === self :: RETURN_DOCUMENT_AFTER ;
89+
90+ unset( $ options [ ' projection ' ], $ options [ ' returnDocument ' ]);
9591
9692 $ this ->findAndModify = new FindAndModify (
9793 $ databaseName ,
9894 $ collectionName ,
9995 array (
100- 'fields ' => isset ($ options ['projection ' ]) ? $ options ['projection ' ] : null ,
101- 'maxTimeMS ' => isset ($ options ['maxTimeMS ' ]) ? $ options ['maxTimeMS ' ] : null ,
102- 'new ' => $ options ['returnDocument ' ] === self ::RETURN_DOCUMENT_AFTER ,
10396 'query ' => $ filter ,
104- 'sort ' => isset ($ options ['sort ' ]) ? $ options ['sort ' ] : null ,
10597 'update ' => $ replacement ,
106- 'upsert ' => $ options ['upsert ' ],
107- )
98+ ) + $ options
10899 );
109100 }
110101
0 commit comments