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

InnerHitsFilter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 2
c 1
b 1
f 0
lcom 1
cbo 1
dl 0
loc 29
ccs 14
cts 14
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A query() 0 15 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