Completed
Pull Request — master (#110)
by
unknown
03:12
created

SignificantTermsAggregation   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 1
cbo 3
dl 0
loc 45
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A getType() 0 4 1
A getArray() 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\Aggregation;
13
14
use ONGR\ElasticsearchDSL\Aggregation\Type\BucketingTrait;
15
use ONGR\ElasticsearchDSL\ScriptAwareTrait;
16
17
/**
18
 * Class representing TermsAggregation.
19
 */
20
class SignificantTermsAggregation extends AbstractAggregation
21
{
22
    use BucketingTrait;
23
    use ScriptAwareTrait;
24
25
    /**
26
     * Inner aggregations container init.
27
     *
28
     * @param string $name
29
     * @param string $field
30
     * @param array $parameters
31
     * @param string $script
32
     */
33
    public function __construct($name, $field = null, $parameters = [], $script = null)
34
    {
35
        parent::__construct($name);
36
37
        $this->setField($field);
38
        $this->setScript($script);
39
        $this->setParameters($parameters);
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45
    public function getType()
46
    {
47
        return 'significant_terms';
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53
    public function getArray()
54
    {
55
        $data = array_filter(
56
            [
57
                'field' => $this->getField(),
58
                'script' => $this->getScript(),
59
            ]
60
        );
61
        $data = $this->processArray($data);
62
        return $data;
63
    }
64
}
65