@@ -68,10 +68,6 @@ public function __construct($databaseName, $collectionName, $filter, $replacemen
68
68
'upsert ' => false ,
69
69
);
70
70
71
- if (isset ($ options ['maxTimeMS ' ]) && ! is_integer ($ options ['maxTimeMS ' ])) {
72
- throw new InvalidArgumentTypeException ('"maxTimeMS" option ' , $ options ['maxTimeMS ' ], 'integer ' );
73
- }
74
-
75
71
if (isset ($ options ['projection ' ]) && ! is_array ($ options ['projection ' ]) && ! is_object ($ options ['projection ' ])) {
76
72
throw new InvalidArgumentTypeException ('"projection" option ' , $ options ['projection ' ], 'array or object ' );
77
73
}
@@ -85,26 +81,21 @@ public function __construct($databaseName, $collectionName, $filter, $replacemen
85
81
throw new InvalidArgumentException ('Invalid value for "returnDocument" option: ' . $ options ['returnDocument ' ]);
86
82
}
87
83
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 ' ] ;
90
86
}
91
87
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 ' ]);
95
91
96
92
$ this ->findAndModify = new FindAndModify (
97
93
$ databaseName ,
98
94
$ collectionName ,
99
95
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 ,
103
96
'query ' => $ filter ,
104
- 'sort ' => isset ($ options ['sort ' ]) ? $ options ['sort ' ] : null ,
105
97
'update ' => $ replacement ,
106
- 'upsert ' => $ options ['upsert ' ],
107
- )
98
+ ) + $ options
108
99
);
109
100
}
110
101
0 commit comments