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