|
|
@@ -282,9 +282,7 @@ class MongoCollection
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- if (! count((array)$a)) {
|
|
|
- throw new \MongoException('document must be an array or object');
|
|
|
- }
|
|
|
+ $this->mustBeArrayOrObject($a);
|
|
|
|
|
|
try {
|
|
|
$result = $this->collection->insertOne(
|
|
|
@@ -1038,4 +1036,11 @@ class MongoCollection
|
|
|
{
|
|
|
return ['db', 'name'];
|
|
|
}
|
|
|
+
|
|
|
+ private function mustBeArrayOrObject($a)
|
|
|
+ {
|
|
|
+ if (!is_array($a) && !is_object($a)) {
|
|
|
+ throw new \MongoException('document must be an array or object');
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|