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