diff --git a/Query/DisMaxQuery.php b/Query/DisMaxQuery.php index f457f7d45ac5d534e49abf0301d92b3ba45351cc..776a0122b260e64fe1967f51f2d9f9daa40dd03d 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()]; }