Completed
Pull Request — master (#22)
by Sergey
12:24
created

ElasticsearchCollectionResponse   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 0
dl 0
loc 49
rs 10
c 0
b 0
f 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getTook() 0 4 1
A isTimedOut() 0 4 1
A getTotalShards() 0 4 1
A getSuccessfulShardsCount() 0 4 1
A getFailedShardsCount() 0 4 1
A getTotal() 0 4 1
A getMaxScore() 0 4 1
A hits() 0 4 1
1
<?php
2
3
namespace Isswp101\Persimmon\Response;
4
5
class ElasticsearchCollectionResponse
6
{
7
    private $response;
8
9
    public function __construct(array $response)
10
    {
11
        $this->response = $response;
12
    }
13
14
    public function getTook(): int
15
    {
16
        return $this->response['took'] ?? 0;
17
    }
18
19
    public function isTimedOut(): bool
20
    {
21
        return $this->response['timed_out'] ?? false;
22
    }
23
24
    public function getTotalShards(): int
25
    {
26
        return $this->response['_shards']['total'] ?? 0;
27
    }
28
29
    public function getSuccessfulShardsCount(): int
30
    {
31
        return $this->response['_shards']['successful'] ?? 0;
32
    }
33
34
    public function getFailedShardsCount(): int
35
    {
36
        return $this->response['_shards']['failed'] ?? 0;
37
    }
38
39
    public function getTotal(): int
40
    {
41
        return $this->response['hits']['total'] ?? 0;
42
    }
43
44
    public function getMaxScore(): int
45
    {
46
        return $this->response['hits']['max_score'] ?? 0;
47
    }
48
49
    public function hits(): array
50
    {
51
        return $this->response['hits']['hits'] ?? [];
52
    }
53
}