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,9 +89,12 @@ class Add extends Command
*/
public function addDocuments($documents)
{
foreach ($documents as $document) {
if (!($document instanceof DocumentInterface)) {
throw new RuntimeException('Documents must implement DocumentInterface.');
//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.');
}
}
}
......
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