Total Complexity | 9 |
Total Lines | 100 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 0 |
1 | <?php |
||
6 | class SearchResult |
||
7 | { |
||
8 | /** @var int */ |
||
9 | private $took; |
||
10 | |||
11 | /** @var bool */ |
||
12 | private $timedOut; |
||
13 | |||
14 | /** @var array */ |
||
15 | private $shards; |
||
16 | |||
17 | /** @var Collection */ |
||
18 | private $hits; |
||
19 | |||
20 | /** @var int */ |
||
21 | private $totalHits; |
||
22 | |||
23 | /** @var float */ |
||
24 | private $maxScore; |
||
25 | |||
26 | /** @var array|null */ |
||
27 | private $aggregation; |
||
28 | |||
29 | /** |
||
30 | * SearchResult constructor. |
||
31 | * @param array $result |
||
32 | */ |
||
33 | public function __construct(array $result) |
||
34 | { |
||
35 | $this->took = (int)array_get($result, 'took'); |
||
36 | $this->timedOut = (bool)array_get($result, 'timed_out'); |
||
37 | $this->shards = (array)array_get($result, '_shards'); |
||
38 | $this->hits = new Collection(array_get($result, 'hits.hits')); |
||
39 | $this->totalHits = (int)array_get($result, 'hits.total'); |
||
40 | $this->maxScore = (float)array_get($result, 'hits.max_score'); |
||
41 | $this->aggregation = array_get($result, 'aggregations', null); |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * @return int |
||
46 | */ |
||
47 | public function getTook(): int |
||
48 | { |
||
49 | return $this->took; |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * @return bool |
||
54 | */ |
||
55 | public function isTimedOut(): bool |
||
56 | { |
||
57 | return $this->timedOut; |
||
58 | } |
||
59 | |||
60 | /** |
||
61 | * @return array |
||
62 | */ |
||
63 | public function getShards(): array |
||
64 | { |
||
65 | return $this->shards; |
||
66 | } |
||
67 | |||
68 | /** |
||
69 | * @return Collection |
||
70 | */ |
||
71 | public function getHits(): Collection |
||
72 | { |
||
73 | return $this->hits; |
||
74 | } |
||
75 | |||
76 | /** |
||
77 | * @param Collection $hits |
||
78 | */ |
||
79 | public function setHits(Collection $hits) |
||
82 | } |
||
83 | |||
84 | /** |
||
85 | * @return int |
||
86 | */ |
||
87 | public function getTotalHits(): int |
||
90 | } |
||
91 | |||
92 | /** |
||
93 | * @return float |
||
94 | */ |
||
95 | public function getMaxScore(): float |
||
96 | { |
||
97 | return $this->maxScore; |
||
98 | } |
||
99 | |||
100 | /** |
||
101 | * @return array|null |
||
102 | */ |
||
103 | public function getAggregation(): ?array |
||
106 | } |
||
107 | } |
||
108 |