From a100480c86586e95de8a59bc1be8b9eb0490c772 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mantas=20Jonu=C5=A1as?= <mantas.jonusas@nfq.lt> Date: Thu, 19 Mar 2015 13:10:52 +0200 Subject: [PATCH] Added addQuery() method in DisMaxQuery --- Query/DisMaxQuery.php | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/Query/DisMaxQuery.php b/Query/DisMaxQuery.php index f457f7d..776a012 100644 --- a/Query/DisMaxQuery.php +++ b/Query/DisMaxQuery.php @@ -29,23 +29,27 @@ class DisMaxQuery implements BuilderInterface /** * Initializes Dis Max query. * - * @param BuilderInterface[] $queries - * @param array $parameters - * - * @throws \InvalidArgumentException + * @param array $parameters */ - public function __construct(array $queries = [], array $parameters = []) + public function __construct(array $parameters = []) { - foreach ($queries as $query) { - if ($query instanceof BuilderInterface) { - $this->queries[] = $query; - } else { - throw new \InvalidArgumentException('Arguments must be instance of BuilderInterface'); - } - } $this->setParameters($parameters); } + /** + * Add query. + * + * @param BuilderInterface $query + * + * @return $this + */ + public function addQuery(BuilderInterface $query) + { + $this->queries[] = $query; + + return $this; + } + /** * {@inheritdoc} */ @@ -59,6 +63,7 @@ class DisMaxQuery implements BuilderInterface */ public function toArray() { + $query = []; foreach ($this->queries as $type) { $query['queries'][] = [$type->getType() => $type->toArray()]; } -- GitLab