Completed
Push — master ( ab4a72...99f0f9 )
by Sergey
05:20
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

Importance

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