Completed
Push — master ( 4e3586...47872e )
by Sergey
05:37
created

InnerHitsFilter::query()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 1

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 15
ccs 9
cts 9
cp 1
rs 9.4285
cc 1
eloc 9
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Isswp101\Persimmon\QueryBuilder\Filters;
4
5
class InnerHitsFilter extends Filter
6
{
7
    protected $parentType;
8
    protected $fields = [];
9
10 2
    public function __construct($parentType, array $fields = [])
11
    {
12 2
        parent::__construct();
13
14 2
        $this->parentType = $parentType;
15 2
        $this->fields = $fields;
16 2
    }
17
18 2
    public function query($values)
19
    {
20
        $query = [
21
            'has_parent' => [
22 2
                'type' => $this->parentType,
23
                'filter' => [
24 2
                    'match_all' => []
25 2
                ],
26
                'inner_hits' => [
27 2
                    '_source' => $this->fields
28 2
                ]
29 2
            ]
30 2
        ];
31 2
        return $query;
32
    }
33
}
34