Passed
Branch master (8cb5b2)
by Christopher
04:37
created

InnerHit   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 46
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A parentInnerHit() 0 13 2
A nestedInnerHit() 0 13 2
1
<?php
2
namespace Triadev\Leopard\Business\Dsl\Query;
3
4
use ONGR\ElasticsearchDSL\InnerHit\NestedInnerHit;
5
use ONGR\ElasticsearchDSL\InnerHit\ParentInnerHit;
6
use Triadev\Leopard\Business\Dsl\Search;
7
use Triadev\Leopard\Business\Dsl\AbstractQuery;
8
9
class InnerHit extends AbstractQuery
10
{
11
    /**
12
     * Nested inner hit
13
     *
14
     * @param string $name
15
     * @param string $path
16
     * @param \Closure|null $search
17
     * @return InnerHit
18
     */
19 2
    public function nestedInnerHit(string $name, string $path, ?\Closure $search = null) : InnerHit
20
    {
21 2
        $searchForNested = null;
22
        
23 2
        if ($search) {
24 2
            $searchBuilder = app()->make(Search::class);
25 2
            $search($searchBuilder);
26
            
27 2
            $searchForNested = $searchBuilder->getSearch();
28
        }
29
        
30 2
        $this->search->addInnerHit(new NestedInnerHit($name, $path, $searchForNested));
31 2
        return $this;
32
    }
33
    
34
    /**
35
     * Parent inner hits
36
     *
37
     * @param string $name
38
     * @param string $path
39
     * @param \Closure|null $search
40
     * @return InnerHit
41
     */
42 1
    public function parentInnerHit(string $name, string $path, ?\Closure $search = null) : InnerHit
43
    {
44 1
        $searchForNested = null;
45
        
46 1
        if ($search) {
47 1
            $searchBuilder = app()->make(Search::class);
48 1
            $search($searchBuilder);
49
            
50 1
            $searchForNested = $searchBuilder->getSearch();
51
        }
52
        
53 1
        $this->search->addInnerHit(new ParentInnerHit($name, $path, $searchForNested));
54 1
        return $this;
55
    }
56
}
57