Completed
Push — master ( a655ed...83d1a6 )
by Federico
02:11
created

BucketSelector::__construct()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 12

Duplication

Lines 12
Ratio 100 %

Importance

Changes 0
Metric Value
dl 12
loc 12
rs 9.8666
c 0
b 0
f 0
cc 3
nc 4
nop 3
1
<?php
2
namespace Elastica\Aggregation;
3
4
/**
5
 * Class BucketSelector.
6
 * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-bucket-selector-aggregation.html
7
 */
8
class BucketSelector extends AbstractSimpleAggregation
9
{
10
    /**
11
     * @param string      $name
12
     * @param array|null  $bucketsPath
13
     * @param string|null $script
14
     */
15 View Code Duplication
    public function __construct(string $name, array $bucketsPath = null, string $script = null)
0 ignored issues
show
Duplication introduced by
This method 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...
16
    {
17
        parent::__construct($name);
18
19
        if ($bucketsPath !== null) {
20
            $this->setBucketsPath($bucketsPath);
21
        }
22
23
        if ($script !== null) {
24
            $this->setScript($script);
25
        }
26
    }
27
28
    /**
29
     * Set the buckets_path for this aggregation.
30
     *
31
     * @param array $bucketsPath
32
     *
33
     * @return $this
34
     */
35
    public function setBucketsPath($bucketsPath)
36
    {
37
        return $this->setParam('buckets_path', $bucketsPath);
38
    }
39
40
    /**
41
     * Set the gap policy for this aggregation.
42
     *
43
     * @param string $gapPolicy
44
     *
45
     * @return $this
46
     */
47
    public function setGapPolicy(string $gapPolicy = 'skip')
48
    {
49
        return $this->setParam('gap_policy', $gapPolicy);
50
    }
51
}
52
53