Code Duplication    Length = 41-43 lines in 2 locations

src/Aggregation/SignificantTermsAggregation.php 1 location

@@ 20-60 (lines=41) @@
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
     */
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

src/Aggregation/TermsAggregation.php 1 location

@@ 20-62 (lines=43) @@
17
/**
18
 * Class representing TermsAggregation.
19
 */
20
class TermsAggregation 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 string $script
31
     */
32
    public function __construct($name, $field = null, $script = null)
33
    {
34
        parent::__construct($name);
35
36
        $this->setField($field);
37
        $this->setScript($script);
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43
    public function getType()
44
    {
45
        return 'terms';
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51
    public function getArray()
52
    {
53
        $data = array_filter(
54
            [
55
                'field' => $this->getField(),
56
                'script' => $this->getScript(),
57
            ]
58
        );
59
60
        return $data;
61
    }
62
}
63