Completed
Push — master ( 6c9334...f3ba17 )
by Simonas
02:26
created

NestedQuery   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 1
cbo 2
dl 0
loc 49
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getType() 0 4 1
A toArray() 0 11 1
1
<?php
2
3
/*
4
 * This file is part of the ONGR package.
5
 *
6
 * (c) NFQ Technologies UAB <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace ONGR\ElasticsearchDSL\Query\Joining;
13
14
use ONGR\ElasticsearchDSL\BuilderInterface;
15
use ONGR\ElasticsearchDSL\ParametersTrait;
16
17
/**
18
 * Represents Elasticsearch "nested" query.
19
 *
20
 * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-nested-query.html
21
 */
22
class NestedQuery implements BuilderInterface
23
{
24
    use ParametersTrait;
25
26
    /**
27
     * @var string
28
     */
29
    private $path;
30
31
    /**
32
     * @var BuilderInterface
33
     */
34
    private $query;
35
36
    /**
37
     * @param string           $path
38
     * @param BuilderInterface $query
39
     * @param array            $parameters
40
     */
41
    public function __construct($path, BuilderInterface $query, array $parameters = [])
42
    {
43
        $this->path = $path;
44
        $this->query = $query;
45
        $this->parameters = $parameters;
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51
    public function getType()
52
    {
53
        return 'nested';
54
    }
55
56
    /**
57
     * {@inheritdoc}
58
     */
59
    public function toArray()
60
    {
61
        return [
62
            $this->getType() => $this->processArray(
63
                [
64
                    'path' => $this->path,
65
                    'query' => $this->query->toArray(),
66
                ]
67
            )
68
        ];
69
    }
70
}
71