Completed
Push — master ( be5d10...3892c2 )
by Sergey
07:31
created

InnerHits::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1.0156

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 4
cp 0.75
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1.0156
1
<?php
2
3
namespace Isswp101\Persimmon\Elasticsearch;
4
5
use Illuminate\Support\Arr;
6
7
class InnerHits
8
{
9
    protected $hits = [];
10
11 10
    public function __construct(array $response)
12
    {
13 10
        $this->hits = Arr::get($response, 'inner_hits', []);
14 10
    }
15
16 10
    public function getParentId($parentType)
17
    {
18 10
        return Arr::get($this->hits, $parentType . '.hits.hits.0._id');
19
    }
20
21 1
    public function getParent($parentType)
22
    {
23 1
        return Arr::get($this->hits, $parentType . '.hits.hits.0._source');
24
    }
25
26
    public function get()
27
    {
28
        return $this->hits;
29
    }
30
}
31