Total Complexity | 6 |
Total Lines | 48 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php namespace Nord\Lumen\Elasticsearch\Search\Query\TermLevel; |
||
8 | class TermQuery extends AbstractQuery |
||
9 | { |
||
10 | |||
11 | use BoostableQuery; |
||
12 | |||
13 | /** |
||
14 | * @var mixed |
||
15 | */ |
||
16 | private $value; |
||
17 | |||
18 | |||
19 | /** |
||
20 | * @inheritdoc |
||
21 | */ |
||
22 | public function toArray() |
||
23 | { |
||
24 | $term = ['value' => $this->getValue()]; |
||
25 | |||
26 | $boost = $this->getBoost(); |
||
27 | if (!is_null($boost)) { |
||
28 | $term['boost'] = $boost; |
||
29 | } |
||
30 | |||
31 | if (count($term) === 1 && isset($term['value'])) { |
||
32 | $term = $term['value']; |
||
33 | } |
||
34 | |||
35 | return ['term' => [$this->getField() => $term]]; |
||
36 | } |
||
37 | |||
38 | |||
39 | /** |
||
40 | * @param mixed $value |
||
41 | * @return TermQuery |
||
42 | */ |
||
43 | public function setValue($value) |
||
44 | { |
||
45 | $this->value = $value; |
||
46 | return $this; |
||
47 | } |
||
48 | |||
49 | |||
50 | /** |
||
51 | * @return mixed |
||
52 | */ |
||
53 | public function getValue() |
||
56 | } |
||
57 | } |
||
58 |