Completed
Pull Request — master (#148)
by Simonas
05:22
created

NestedAggregation   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 58
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getPath() 0 4 1
A setPath() 0 4 1
A getType() 0 4 1
A getArray() 0 4 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\Aggregation\Bucketing;
13
14
use ONGR\ElasticsearchDSL\Aggregation\AbstractAggregation;
15
use ONGR\ElasticsearchDSL\Aggregation\Type\BucketingTrait;
16
17
/**
18
 * Class representing NestedAggregation.
19
 *
20
 * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-nested-aggregation.html
21
 */
22
class NestedAggregation extends AbstractAggregation
23
{
24
    use BucketingTrait;
25
26
    /**
27
     * @var string
28
     */
29
    private $path;
30
31
    /**
32
     * Inner aggregations container init.
33
     *
34
     * @param string $name
35
     * @param string $path
36
     */
37
    public function __construct($name, $path = null)
38
    {
39
        parent::__construct($name);
40
41
        $this->setPath($path);
42
    }
43
44
    /**
45
     * Return path.
46
     *
47
     * @return string
48
     */
49
    public function getPath()
50
    {
51
        return $this->path;
52
    }
53
54
    /**
55
     * Sets path.
56
     *
57
     * @param string $path
58
     */
59
    public function setPath($path)
60
    {
61
        $this->path = $path;
62
    }
63
64
    /**
65
     * {@inheritdoc}
66
     */
67
    public function getType()
68
    {
69
        return 'nested';
70
    }
71
72
    /**
73
     * {@inheritdoc}
74
     */
75
    public function getArray()
76
    {
77
        return ['path' => $this->getPath()];
78
    }
79
}
80