Completed
Push — master ( 4cdb71...eee063 )
by Nicolas
02:28
created

SpanTerm::setRawTerm()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
dl 4
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
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
Duplication introduced by
This class seems to be duplicated in your project.

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.

Loading history...
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