Commit 3d2e8828 authored by Douglas Greenshields's avatar Douglas Greenshields

only check type for added documents to add query if provided as an array

parent a9d8a52b
......@@ -89,11 +89,14 @@ class Add extends Command
*/
public function addDocuments($documents)
{
//only check documents for type if in an array (iterating a Traversable may do unnecessary work)
if (is_array($documents)) {
foreach ($documents as $document) {
if (!($document instanceof DocumentInterface)) {
throw new RuntimeException('Documents must implement DocumentInterface.');
}
}
}
//if we don't have documents so far, accept arrays or Traversable objects as-is
if (empty($this->documents)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment