Completed
Pull Request — master (#276)
by
unknown
01:38
created

CountCardinalityAggregation::getArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
declare(strict_types=1);
3
4
namespace ONGR\ElasticsearchDSL\Aggregation\Metric;
5
6
use ONGR\ElasticsearchDSL\Aggregation\AbstractAggregation;
7
8
/**
9
 * Class CountCardinalityAggregation
10
 *
11
 * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-cardinality-aggregation.html
12
 *
13
 * @package ONGR\ElasticsearchDSL\Aggregation\Metric
14
 */
15
class CountCardinalityAggregation extends AbstractAggregation
16
{
17
    /**
18
     * CountAggregation constructor.
19
     * @param $name
20
     * @param null $field
21
     */
22
    public function __construct($name, $field = null)
23
    {
24
        parent::__construct($name);
25
26
        $this->setField($field);
27
    }
28
29
    /**
30
     * @return array|\stdClass
31
     */
32
    protected function getArray()
33
    {
34
        $data = array_filter(
35
            [
36
                'field' => $this->getField(),
37
            ]
38
        );
39
40
        return $data;
41
    }
42
43
    /**
44
     * @return bool
45
     */
46
    protected function supportsNesting()
47
    {
48
        return false;
49
    }
50
51
    /**
52
     * @return string
53
     */
54
    public function getType()
55
    {
56
        return 'cardinality';
57
    }
58
}
59