1<?php 2 3namespace Elastica\Query; 4 5use Elastica\Exception\InvalidException; 6 7/** 8 * SpanMulti query. 9 * 10 * @author Marek Hernik <marek.hernik@gmail.com> 11 * @author Alessandro Chitolina <alekitto@gmail.com> 12 * 13 * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-multi-term-query.html 14 */ 15class SpanMulti extends AbstractSpanQuery 16{ 17 /** 18 * Constructs a SpanMulti query object. 19 * 20 * @param AbstractQuery|array $match 21 */ 22 public function __construct($match = null) 23 { 24 if (null !== $match) { 25 $this->setMatch($match); 26 } 27 } 28 29 /** 30 * Set the query to be wrapped into the span multi query. 31 * 32 * @param AbstractQuery|array $args Matching query 33 * 34 * @return $this 35 */ 36 public function setMatch($args): self 37 { 38 return $this->_setQuery('match', $args); 39 } 40 41 /** 42 * Sets a query to the current object. 43 * 44 * @param string $type Query type 45 * @param AbstractQuery|array $args Query 46 * 47 * @throws InvalidException If not valid query 48 * 49 * @return $this 50 */ 51 protected function _setQuery(string $type, $args): self 52 { 53 if (!\is_array($args) && !($args instanceof AbstractQuery)) { 54 throw new InvalidException('Invalid parameter. Has to be array or instance of Elastica\Query\AbstractQuery'); 55 } 56 57 return $this->setParam($type, $args); 58 } 59} 60