Completed
Pull Request — v0.10 (#630)
by Tautrimas
93:19
created

ExtendedStatsAggregation   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getSigma() 0 4 1
A setSigma() 0 4 1
A getType() 0 4 1
A getArray() 0 15 2
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\ElasticsearchBundle\DSL\Aggregation;
13
14
use ONGR\ElasticsearchBundle\DSL\Aggregation\Type\MetricTrait;
15
use ONGR\ElasticsearchBundle\DSL\ScriptAwareTrait;
16
17
/**
18
 * Class representing Extended stats aggregation.
19
 */
20
class ExtendedStatsAggregation extends AbstractAggregation
21
{
22
    use MetricTrait;
23
    use ScriptAwareTrait;
24
25
    /**
26
     * @var int
27
     */
28
    private $sigma;
29
30
    /**
31
     * @return int
32
     */
33
    public function getSigma()
34
    {
35
        return $this->sigma;
36
    }
37
38
    /**
39
     * @param int $sigma
40
     */
41
    public function setSigma($sigma)
42
    {
43
        $this->sigma = $sigma;
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49
    public function getType()
50
    {
51
        return 'extended_stats';
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57
    public function getArray()
58
    {
59
        $out = array_filter(
60
            [
61
                'field' => $this->getField(),
62
                'script' => $this->getScript(),
63
                'sigma' => $this->getSigma(),
64
            ],
65
            function ($val) {
66
                return ($val || is_numeric($val));
67
            }
68
        );
69
70
        return $out;
71
    }
72
}
73