Completed
Push — master ( f63c2e...3d45a5 )
by Sergey
11:19
created

ElasticsearchCollection::isTimedOut()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Isswp101\Persimmon\Cache\Collection;
4
5
use Illuminate\Support\Collection;
6
7
class ElasticsearchCollection extends Collection
8
{
9
    /**
10
     * Elasticsearch response.
11
     *
12
     * @var array
13
     */
14
    protected $response = [];
15
16
    /**
17
     * Put response.
18
     *
19
     * @param array $response
20
     */
21
    public function response(array $response)
22
    {
23
        unset($response['hits']['hits']);
24
        $this->response = $response;
25
    }
26
27
    /**
28
     * @return int
29
     */
30
    public function getTook()
31
    {
32
        return $this->response['took'];
33
    }
34
35
    /**
36
     * @return bool
37
     */
38
    public function isTimedOut()
39
    {
40
        return $this->response['timed_out'];
41
    }
42
43
    /**
44
     * @return int
45
     */
46
    public function getTotal()
47
    {
48
        return $this->response['hits']['total'];
49
    }
50
51
    /**
52
     * @return int
53
     */
54
    public function getMaxScore()
55
    {
56
        return $this->response['hits']['max_score'];
57
    }
58
59
    /**
60
     * @return array
61
     */
62
    public function getShards()
63
    {
64
        return $this->response['_shards'];
65
    }
66
67
    /**
68
     * @param string $name
69
     * @return array
70
     */
71
    public function getAggregation($name)
72
    {
73
        return array_get($this->response, 'aggregations.' . $name . '.buckets', []);
74
    }
75
}