Nested   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 54
ccs 0
cts 22
cp 0
rs 10
c 0
b 0
f 0
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A name() 0 3 1
A __construct() 0 4 1
A compile() 0 16 3
1
<?php
2
/*
3
 * This file is part of PHPinnacle/Elastics.
4
 *
5
 * (c) PHPinnacle Team <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
declare(strict_types=1);
12
13
namespace PHPinnacle\Elastics\Query;
14
15
use PHPinnacle\Elastics\Query;
16
use PHPinnacle\Elastics\Traits;
17
18
class Nested implements Query
19
{
20
    use
21
        Traits\IgnoreUnmapped,
22
        Traits\ScoreMode
23
    ;
24
25
    /**
26
     * @var string
27
     */
28
    private $path;
29
30
    /**
31
     * @var Query
32
     */
33
    private $query;
34
35
    /**
36
     * @param string $path
37
     * @param Query  $query
38
     */
39
    public function __construct(string $path, Query $query)
40
    {
41
        $this->path  = $path;
42
        $this->query = $query;
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function name(): string
49
    {
50
        return 'nested';
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56
    public function compile(): array
57
    {
58
        $query = [
59
            'path'  => $this->path,
60
            'query' => $this->query,
61
        ];
62
63
        if ($this->scoreMode !== null) {
64
            $query['score_mode'] = $this->scoreMode;
65
        }
66
67
        if ($this->ignoreUnmapped !== null) {
68
            $query['ignore_unmapped'] = $this->ignoreUnmapped;
69
        }
70
71
        return $query;
72
    }
73
}
74