1 | <?php |
||
22 | * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-polygon-query.html |
||
23 | */ |
||
24 | class GeoPolygonQuery implements BuilderInterface |
||
25 | { |
||
26 | use ParametersTrait; |
||
27 | |||
28 | public function __construct( |
||
29 | private string $field, |
||
|
|||
30 | private array $points = [], |
||
31 | array $parameters = [] |
||
32 | ) { |
||
33 | $this->setParameters($parameters); |
||
34 | } |
||
35 | |||
36 | public function getType(): string |
||
37 | { |
||
38 | return 'geo_polygon'; |
||
39 | } |
||
40 | |||
41 | public function toArray(): array |
||
42 | { |
||
43 | $query = [$this->field => ['points' => $this->points]]; |
||
44 | $output = $this->processArray($query); |
||
45 | |||
46 | return [$this->getType() => $output]; |
||
47 | } |
||
48 | } |
||
49 |