Total Complexity | 6 |
Total Lines | 54 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | class WildcardQuery extends AbstractQuery |
||
12 | { |
||
13 | |||
14 | use BoostableQuery; |
||
15 | |||
16 | /** |
||
17 | * @var string |
||
18 | */ |
||
19 | private $value; |
||
20 | |||
21 | /** |
||
22 | * @inheritdoc |
||
23 | * |
||
24 | * @throws InvalidArgument |
||
25 | */ |
||
26 | public function toArray() |
||
27 | { |
||
28 | if (!isset($this->field) || !isset($this->value)) { |
||
29 | throw new InvalidArgument('"field" and "value" must be set for this type of query'); |
||
30 | } |
||
31 | |||
32 | $definition = [ |
||
33 | 'value' => $this->getValue(), |
||
34 | ]; |
||
35 | |||
36 | if ($this->hasBoost()) { |
||
37 | $definition['boost'] = $this->getBoost(); |
||
38 | } |
||
39 | |||
40 | return [ |
||
41 | 'wildcard' => [ |
||
42 | $this->getField() => $definition, |
||
43 | ], |
||
44 | ]; |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * @return string |
||
49 | */ |
||
50 | public function getValue() |
||
51 | { |
||
52 | return $this->value; |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * @param string $value |
||
57 | * |
||
58 | * @return $this |
||
59 | */ |
||
60 | public function setValue($value) |
||
65 | } |
||
66 | } |
||
67 |