These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | namespace Elastica\Query; |
||
3 | |||
4 | use Elastica\Exception\InvalidException; |
||
5 | |||
6 | /** |
||
7 | * SpanMulti query. |
||
8 | * |
||
9 | * @author Marek Hernik <[email protected]> |
||
10 | * @author Alessandro Chitolina <[email protected]> |
||
11 | * |
||
12 | * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-multi-term-query.html |
||
13 | */ |
||
14 | class SpanMulti extends AbstractSpanQuery |
||
15 | { |
||
16 | /** |
||
17 | * Constructs a SpanMulti query object. |
||
18 | * |
||
19 | * @param \Elastica\Query\AbstractQuery|array $match OPTIONAL |
||
20 | */ |
||
21 | public function __construct($match = null) |
||
22 | { |
||
23 | if (null !== $match) { |
||
24 | $this->setMatch($match); |
||
25 | } |
||
26 | } |
||
27 | |||
28 | /** |
||
29 | * Set the query to be wrapped into the span multi query. |
||
30 | * |
||
31 | * @param \Elastica\Query\AbstractQuery|array $args Matching query |
||
32 | * |
||
33 | * @return $this |
||
34 | */ |
||
35 | public function setMatch($args) |
||
36 | { |
||
37 | return $this->_setQuery('match', $args); |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * Sets a query to the current object. |
||
42 | * |
||
43 | * @param string $type Query type |
||
44 | * @param \Elastica\Query\AbstractQuery|array $args Query |
||
45 | * |
||
46 | * @throws \Elastica\Exception\InvalidException If not valid query |
||
47 | * |
||
48 | * @return $this |
||
49 | */ |
||
50 | View Code Duplication | protected function _setQuery($type, $args) |
|
0 ignored issues
–
show
|
|||
51 | { |
||
52 | if (!is_array($args) && !($args instanceof AbstractQuery)) { |
||
53 | throw new InvalidException('Invalid parameter. Has to be array or instance of Elastica\Query\AbstractQuery'); |
||
54 | } |
||
55 | |||
56 | return $this->setParam($type, $args); |
||
57 | } |
||
58 | } |
||
59 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.