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

MissingAggregation::getArray()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 2
eloc 4
nc 2
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\Bucketing;
13
14
use ONGR\ElasticsearchDSL\Aggregation\AbstractAggregation;
15
use ONGR\ElasticsearchDSL\Aggregation\Type\BucketingTrait;
16
17
/**
18
 * Class representing missing aggregation.
19
 *
20
 * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-missing-aggregation.html
21
 */
22
class MissingAggregation extends AbstractAggregation
23
{
24
    use BucketingTrait;
25
26
    /**
27
     * Inner aggregations container init.
28
     *
29
     * @param string $name
30
     * @param string $field
31
     */
32
    public function __construct($name, $field = null)
33
    {
34
        parent::__construct($name);
35
36
        $this->setField($field);
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    public function getArray()
43
    {
44
        if ($this->getField()) {
45
            return ['field' => $this->getField()];
46
        }
47
        throw new \LogicException('Missing aggregation must have a field set.');
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53
    public function getType()
54
    {
55
        return 'missing';
56
    }
57
}
58