From 9bd27c2f228066771250d927e6a2f3b2788fe6fb Mon Sep 17 00:00:00 2001
From: Andrew McLagan <andrewmclagan@gmail.com>
Date: Wed, 8 Feb 2017 14:01:32 +1100
Subject: [PATCH] Ability to add multiple queries in a single call

There are situation where adding multiple queries is super beneficial.

This PR enables package users to call `$search->addQueries(...)` in two different ways.

#### Single dimension array parameter

In this case an array of `BuilderInterface $query` are passed to the root `$search->addQuery()` function.

#### Multi dimensional array parameter

In this case an array of arrays is passed in, each member of the array is to match the function signature of `$search->addQuery()` and the PHP 5.4 traversable unpacking language feature is used to parameterise the root `$search->addQuery()` function.
---
 src/Search.php | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/src/Search.php b/src/Search.php
index 4a4f686..4a0b7f0 100644
--- a/src/Search.php
+++ b/src/Search.php
@@ -201,6 +201,28 @@ class Search
 
         return $this;
     }
+    
+    /**
+     * Adds multiple queries to the search.
+     *
+     * @param Array     $query
+     * @param string    $boolType
+     * @param string    $key
+     *
+     * @return $this
+     */
+    public function addQueries(Array $queries)
+    {
+        foreach ($queries as $query) {
+            if (is_array($query)) {
+                $this->addQuery(...$query);    
+            } else {
+                $this->addQuery($query);
+            }
+        }
+
+        return $this;
+    }    
 
     /**
      * Returns endpoint instance.
-- 
GitLab