Completed
Pull Request — master (#113)
by
unknown
09:25
created

AbstractPipelineAggregation::getBucketsPath()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
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\Pipeline;
13
14
use ONGR\ElasticsearchDSL\Aggregation\AbstractAggregation;
15
use ONGR\ElasticsearchDSL\Aggregation\Type\MetricTrait;
16
17
/**
18
 * Abstraction class for pipeline aggregations
19
 */
20
abstract class AbstractPipelineAggregation extends AbstractAggregation
21
{
22
    use MetricTrait;
23
24
    /**
25
     * @var string
26
     */
27
    private $bucketsPath;
28
29
    /**
30
     * @var string
31
     */
32
    private $gapPolicy = 'skip';
33
34
    /**
35
     * @return string
36
     */
37
    abstract public function getPipelineFamily();
38
39
    /**
40
     * @return string
41
     */
42
    public function getBucketsPath()
43
    {
44
        return $this->bucketsPath;
45
    }
46
47
    /**
48
     * @param string $bucketsPath
49
     */
50
    public function setBucketsPath($bucketsPath)
51
    {
52
        $this->bucketsPath = $bucketsPath;
53
    }
54
55
    /**
56
     * @return string
57
     */
58
    public function getGapPolicy()
59
    {
60
        return $this->gapPolicy;
61
    }
62
63
    /**
64
     * @param string $gapPolicy
65
     */
66
    public function setGapPolicy($gapPolicy)
67
    {
68
        if ($gapPolicy != 'skip' || $gapPolicy != 'insert_zeros') {
69
            throw new \LogicException(
70
                'Gap policy of '.$this->getName().
71
                ' aggregation can only be `skip` or `insert_zeros`.'
72
            );
73
        } else {
74
            $this->gapPolicy = $gapPolicy;
75
        }
76
    }
77
}
78