1 | <?php |
||
22 | class TermQuery implements BuilderInterface |
||
23 | { |
||
24 | use ParametersTrait; |
||
25 | |||
26 | public function __construct( |
||
27 | private string $field, |
||
|
|||
28 | private string $value, |
||
29 | array $parameters = [] |
||
30 | ) { |
||
31 | $this->setParameters($parameters); |
||
32 | } |
||
33 | |||
34 | public function getType(): string |
||
35 | { |
||
36 | return 'term'; |
||
37 | } |
||
38 | |||
39 | public function toArray(): array |
||
40 | { |
||
41 | $query = $this->processArray(); |
||
42 | |||
43 | if (empty($query)) { |
||
44 | $query = $this->value; |
||
45 | } else { |
||
46 | $query['value'] = $this->value; |
||
47 | } |
||
48 | |||
49 | $output = [ |
||
50 | $this->field => $query, |
||
51 | ]; |
||
52 | |||
53 | return [$this->getType() => $output]; |
||
54 | } |
||
55 | } |
||
56 |