Completed
Pull Request — master (#110)
by
unknown
04:09 queued 01:29
created

SignificantTermsAggregation::getArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 11
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 11
loc 11
rs 9.4285
cc 1
eloc 6
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\Type\BucketingTrait;
15
use ONGR\ElasticsearchDSL\ScriptAwareTrait;
16
17
/**
18
 * Class representing TermsAggregation.
19
 */
20 View Code Duplication
class SignificantTermsAggregation extends AbstractAggregation
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
21
{
22
    use BucketingTrait;
23
    use ScriptAwareTrait;
24
25
    /**
26
     * Inner aggregations container init.
27
     *
28
     * @param string $name
29
     * @param string $field
30
     */
31
    public function __construct($name, $field = null)
32
    {
33
        parent::__construct($name);
34
35
        $this->setField($field);
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    public function getType()
42
    {
43
        return 'significant_terms';
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49
    public function getArray()
50
    {
51
        $data = array_filter(
52
            [
53
                'field' => $this->getField(),
54
                'script' => $this->getScript(),
55
            ]
56
        );
57
        $data = $this->processArray($data);
58
        return $data;
59
    }
60
}
61