| Total Complexity | 9 |
| Total Lines | 100 |
| Duplicated Lines | 0 % |
| Coverage | 92.31% |
| 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 | 2 | public function __construct(array $result) |
|
| 34 | { |
||
| 35 | 2 | $this->took = (int)array_get($result, 'took'); |
|
| 36 | 2 | $this->timedOut = (bool)array_get($result, 'timed_out'); |
|
| 37 | 2 | $this->shards = (array)array_get($result, '_shards'); |
|
| 38 | 2 | $this->hits = new Collection(array_get($result, 'hits.hits')); |
|
| 39 | 2 | $this->totalHits = (int)array_get($result, 'hits.total'); |
|
| 40 | 2 | $this->maxScore = (float)array_get($result, 'hits.max_score'); |
|
| 41 | 2 | $this->aggregation = array_get($result, 'aggregations', null); |
|
| 42 | 2 | } |
|
| 43 | |||
| 44 | /** |
||
| 45 | * @return int |
||
| 46 | */ |
||
| 47 | 2 | public function getTook(): int |
|
| 48 | { |
||
| 49 | 2 | return $this->took; |
|
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @return bool |
||
| 54 | */ |
||
| 55 | 2 | public function isTimedOut(): bool |
|
| 56 | { |
||
| 57 | 2 | return $this->timedOut; |
|
| 58 | } |
||
| 59 | |||
| 60 | /** |
||
| 61 | * @return array |
||
| 62 | */ |
||
| 63 | 2 | public function getShards(): array |
|
| 66 | } |
||
| 67 | |||
| 68 | /** |
||
| 69 | * @return Collection |
||
| 70 | */ |
||
| 71 | 2 | public function getHits(): Collection |
|
| 72 | { |
||
| 73 | 2 | return $this->hits; |
|
| 74 | } |
||
| 75 | |||
| 76 | /** |
||
| 77 | * @param Collection $hits |
||
| 78 | */ |
||
| 79 | 1 | public function setHits(Collection $hits) |
|
| 82 | 1 | } |
|
| 83 | |||
| 84 | /** |
||
| 85 | * @return int |
||
| 86 | */ |
||
| 87 | 2 | public function getTotalHits(): int |
|
| 88 | { |
||
| 89 | 2 | return $this->totalHits; |
|
| 90 | } |
||
| 91 | |||
| 92 | /** |
||
| 93 | * @return float |
||
| 94 | */ |
||
| 95 | 2 | public function getMaxScore(): float |
|
| 96 | { |
||
| 97 | 2 | return $this->maxScore; |
|
| 98 | } |
||
| 99 | |||
| 100 | /** |
||
| 101 | * @return array|null |
||
| 102 | */ |
||
| 103 | public function getAggregation(): ?array |
||
| 106 | } |
||
| 107 | } |
||
| 108 |