Completed
Pull Request — master (#75)
by
unknown
05:53
created

RawAggregation::supportsNesting()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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;
13
14
use ONGR\ElasticsearchDSL\Aggregation\AbstractAggregation;
15
16
class RawAggregation extends AbstractAggregation
17
{
18
    /**
19
     * @var string
20
     */
21
    private $type;
22
    /**
23
     * @var array
24
     */
25
    private $body;
26
27
    /**
28
     * Inner aggregations container init.
29
     *
30
     * @param string $type
31
     * @param string $name
32
     * @param array $body
33
     */
34
    public function __construct($type, $name, $body)
35
    {
36
        $this->type = $type;
37
        parent::__construct($name);
38
39
        if (isset($body['aggregations'])) {
40
            foreach ($body['aggregations'] as $aggregation) {
41
                $this->addAggregation($aggregation);
42
            }
43
            unset($body['aggregations']);
44
        }
45
46
        $this->body = $body;
47
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52
    public function getType()
53
    {
54
        return $this->type;
55
    }
56
57
    /**
58
     * {@inheritdoc}
59
     */
60
    protected function supportsNesting()
61
    {
62
        return true;
63
    }
64
65
    /**
66
     * {@inheritdoc}
67
     */
68
    protected function getArray()
69
    {
70
        return $this->body;
71
    }
72
}