7
7
use MongoDB \Driver \Server ;
8
8
use MongoDB \Driver \WriteConcern ;
9
9
use MongoDB \Exception \InvalidArgumentException ;
10
- use MongoDB \Exception \InvalidArgumentTypeException ;
11
10
12
11
/**
13
12
* Operation for executing multiple write operations.
@@ -85,7 +84,7 @@ public function __construct($databaseName, $collectionName, array $operations, a
85
84
}
86
85
87
86
if ( ! is_array ($ operation )) {
88
- throw new InvalidArgumentTypeException (sprintf ('$operations[%d] ' , $ i ), $ operation , 'array ' );
87
+ throw InvalidArgumentException:: invalidType (sprintf ('$operations[%d] ' , $ i ), $ operation , 'array ' );
89
88
}
90
89
91
90
if (count ($ operation ) !== 1 ) {
@@ -100,7 +99,7 @@ public function __construct($databaseName, $collectionName, array $operations, a
100
99
}
101
100
102
101
if ( ! is_array ($ args [0 ]) && ! is_object ($ args [0 ])) {
103
- throw new InvalidArgumentTypeException (sprintf ('$operations[%d]["%s"][0] ' , $ i , $ type ), $ args [0 ], 'array or object ' );
102
+ throw InvalidArgumentException:: invalidType (sprintf ('$operations[%d]["%s"][0] ' , $ i , $ type ), $ args [0 ], 'array or object ' );
104
103
}
105
104
106
105
switch ($ type ) {
@@ -119,7 +118,7 @@ public function __construct($databaseName, $collectionName, array $operations, a
119
118
}
120
119
121
120
if ( ! is_array ($ args [1 ]) && ! is_object ($ args [1 ])) {
122
- throw new InvalidArgumentTypeException (sprintf ('$operations[%d]["%s"][1] ' , $ i , $ type ), $ args [1 ], 'array or object ' );
121
+ throw InvalidArgumentException:: invalidType (sprintf ('$operations[%d]["%s"][1] ' , $ i , $ type ), $ args [1 ], 'array or object ' );
123
122
}
124
123
125
124
if (\MongoDB \is_first_key_operator ($ args [1 ])) {
@@ -131,14 +130,14 @@ public function __construct($databaseName, $collectionName, array $operations, a
131
130
}
132
131
133
132
if ( ! is_array ($ args [2 ])) {
134
- throw new InvalidArgumentTypeException (sprintf ('$operations[%d]["%s"][2] ' , $ i , $ type ), $ args [2 ], 'array ' );
133
+ throw InvalidArgumentException:: invalidType (sprintf ('$operations[%d]["%s"][2] ' , $ i , $ type ), $ args [2 ], 'array ' );
135
134
}
136
135
137
136
$ args [2 ]['multi ' ] = false ;
138
137
$ args [2 ] += ['upsert ' => false ];
139
138
140
139
if ( ! is_bool ($ args [2 ]['upsert ' ])) {
141
- throw new InvalidArgumentTypeException (sprintf ('$operations[%d]["%s"][2]["upsert"] ' , $ i , $ type ), $ args [2 ]['upsert ' ], 'boolean ' );
140
+ throw InvalidArgumentException:: invalidType (sprintf ('$operations[%d]["%s"][2]["upsert"] ' , $ i , $ type ), $ args [2 ]['upsert ' ], 'boolean ' );
142
141
}
143
142
144
143
$ operations [$ i ][$ type ][2 ] = $ args [2 ];
@@ -152,7 +151,7 @@ public function __construct($databaseName, $collectionName, array $operations, a
152
151
}
153
152
154
153
if ( ! is_array ($ args [1 ]) && ! is_object ($ args [1 ])) {
155
- throw new InvalidArgumentTypeException (sprintf ('$operations[%d]["%s"][1] ' , $ i , $ type ), $ args [1 ], 'array or object ' );
154
+ throw InvalidArgumentException:: invalidType (sprintf ('$operations[%d]["%s"][1] ' , $ i , $ type ), $ args [1 ], 'array or object ' );
156
155
}
157
156
158
157
if ( ! \MongoDB \is_first_key_operator ($ args [1 ])) {
@@ -164,14 +163,14 @@ public function __construct($databaseName, $collectionName, array $operations, a
164
163
}
165
164
166
165
if ( ! is_array ($ args [2 ])) {
167
- throw new InvalidArgumentTypeException (sprintf ('$operations[%d]["%s"][2] ' , $ i , $ type ), $ args [2 ], 'array ' );
166
+ throw InvalidArgumentException:: invalidType (sprintf ('$operations[%d]["%s"][2] ' , $ i , $ type ), $ args [2 ], 'array ' );
168
167
}
169
168
170
169
$ args [2 ]['multi ' ] = ($ type === self ::UPDATE_MANY );
171
170
$ args [2 ] += ['upsert ' => false ];
172
171
173
172
if ( ! is_bool ($ args [2 ]['upsert ' ])) {
174
- throw new InvalidArgumentTypeException (sprintf ('$operations[%d]["%s"][2]["upsert"] ' , $ i , $ type ), $ args [2 ]['upsert ' ], 'boolean ' );
173
+ throw InvalidArgumentException:: invalidType (sprintf ('$operations[%d]["%s"][2]["upsert"] ' , $ i , $ type ), $ args [2 ]['upsert ' ], 'boolean ' );
175
174
}
176
175
177
176
$ operations [$ i ][$ type ][2 ] = $ args [2 ];
@@ -188,15 +187,15 @@ public function __construct($databaseName, $collectionName, array $operations, a
188
187
$ options += ['ordered ' => true ];
189
188
190
189
if (isset ($ options ['bypassDocumentValidation ' ]) && ! is_bool ($ options ['bypassDocumentValidation ' ])) {
191
- throw new InvalidArgumentTypeException ('"bypassDocumentValidation" option ' , $ options ['bypassDocumentValidation ' ], 'boolean ' );
190
+ throw InvalidArgumentException:: invalidType ('"bypassDocumentValidation" option ' , $ options ['bypassDocumentValidation ' ], 'boolean ' );
192
191
}
193
192
194
193
if ( ! is_bool ($ options ['ordered ' ])) {
195
- throw new InvalidArgumentTypeException ('"ordered" option ' , $ options ['ordered ' ], 'boolean ' );
194
+ throw InvalidArgumentException:: invalidType ('"ordered" option ' , $ options ['ordered ' ], 'boolean ' );
196
195
}
197
196
198
197
if (isset ($ options ['writeConcern ' ]) && ! $ options ['writeConcern ' ] instanceof WriteConcern) {
199
- throw new InvalidArgumentTypeException ('"writeConcern" option ' , $ options ['writeConcern ' ], 'MongoDB\Driver\WriteConcern ' );
198
+ throw InvalidArgumentException:: invalidType ('"writeConcern" option ' , $ options ['writeConcern ' ], 'MongoDB\Driver\WriteConcern ' );
200
199
}
201
200
202
201
$ this ->databaseName = (string ) $ databaseName ;
0 commit comments