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 | /** |
||
5 | * SpanTerm query. |
||
6 | * |
||
7 | * @author Alessandro Chitolina <[email protected]> |
||
8 | * @author Marek Hernik <[email protected]> |
||
9 | * |
||
10 | * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-term-query.html |
||
11 | */ |
||
12 | View Code Duplication | class SpanTerm extends AbstractSpanQuery |
|
0 ignored issues
–
show
|
|||
13 | { |
||
14 | /** |
||
15 | * Constructs the SpanTerm query object. |
||
16 | * |
||
17 | * @param array $term OPTIONAL Calls setRawTerm with the given $term array |
||
18 | */ |
||
19 | public function __construct(array $term = []) |
||
20 | { |
||
21 | $this->setRawTerm($term); |
||
22 | } |
||
23 | |||
24 | /** |
||
25 | * Set term can be used instead of setTerm if some more special |
||
26 | * values for a term have to be set. |
||
27 | * |
||
28 | * @param array $term Term array |
||
29 | * |
||
30 | * @return $this |
||
31 | */ |
||
32 | public function setRawTerm(array $term) |
||
33 | { |
||
34 | return $this->setParams($term); |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * Adds a term to the term query. |
||
39 | * |
||
40 | * @param string $key Key to query |
||
41 | * @param string|array $value Values(s) for the query. Boost can be set with array |
||
42 | * @param float $boost OPTIONAL Boost value (default = 1.0) |
||
43 | * |
||
44 | * @return $this |
||
45 | */ |
||
46 | public function setTerm($key, $value, $boost = 1.0) |
||
47 | { |
||
48 | return $this->setRawTerm([$key => ['value' => $value, 'boost' => $boost]]); |
||
49 | } |
||
50 | } |
||
51 |
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.