See More

$shape */ public function __construct( private string $field, private array $shape, private string $relation = 'intersects', private bool|null $ignoreUnmapped = null, ) { if ( ! \in_array($relation, ['intersects', 'disjoint', 'within', 'contains'], true)) { throw new \Spameri\ElasticQuery\Exception\InvalidArgumentException( 'Shape relation must be one of: intersects, disjoint, within, contains.', ); } } public function key(): string { return 'shape_' . $this->field; } /** * @return array>> */ public function toArray(): array { $inner = [ 'shape' => $this->shape, 'relation' => $this->relation, ]; if ($this->ignoreUnmapped !== null) { $inner['ignore_unmapped'] = $this->ignoreUnmapped; } return [ 'shape' => [ $this->field => $inner, ], ]; } }