-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathNested.php
More file actions
51 lines (36 loc) · 843 Bytes
/
Nested.php
File metadata and controls
51 lines (36 loc) · 843 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php declare(strict_types = 1);
namespace Spameri\ElasticQuery\Query;
class Nested implements \Spameri\ElasticQuery\Query\LeafQueryInterface
{
private string $path;
private \Spameri\ElasticQuery\Query\QueryCollection $query;
public function __construct(
string $path,
?\Spameri\ElasticQuery\Query\QueryCollection $query = NULL
) {
$this->path = $path;
if ($query === NULL) {
$query = new \Spameri\ElasticQuery\Query\QueryCollection();
}
$this->query = $query;
}
public function key(): string
{
return 'nested_' . $this->path;
}
public function toArray(): array
{
return [
'nested' => [
'path' => $this->path,
'query' => [
'bool' => $this->query->toArray(),
],
],
];
}
public function getQuery(): \Spameri\ElasticQuery\Query\QueryCollection
{
return $this->query;
}
}