Completed
Push — master ( 2542ad...8d7496 )
by Simonas
04:52 queued 02:07
created

SamplerAggregation::getShardSize()   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;
13
14
use ONGR\ElasticsearchDSL\Aggregation\Type\BucketingTrait;
15
16
/**
17
 * Class representing geo bounds aggregation.
18
 *
19
 * @link https://www.elastic.co/guide/en/elasticsearch/reference/2.3/search-aggregations-bucket-sampler-aggregation.html
20
 */
21
class SamplerAggregation extends AbstractAggregation
22
{
23
    use BucketingTrait;
24
25
    /**
26
     * Defines how many results will be received from each shard
27
     * @param string $shardSize
28
     */
29
    private $shardSize;
30
31
    /**
32
     * Inner aggregations container init.
33
     *
34
     * @param string $name
35
     * @param string $field
36
     * @param int    $shardSize
37
     */
38
    public function __construct(
39
        $name,
40
        $field = null,
41
        $shardSize = null
42
    ) {
43
        parent::__construct($name);
44
45
        $this->setField($field);
46
        $this->setShardSize($shardSize);
47
    }
48
49
    /**
50
     * @return int
51
     */
52
    public function getShardSize()
53
    {
54
        return $this->shardSize;
55
    }
56
57
    /**
58
     * @param int $shardSize
59
     */
60
    public function setShardSize($shardSize)
61
    {
62
        $this->shardSize = $shardSize;
63
    }
64
65
    /**
66
     * {@inheritdoc}
67
     */
68
    public function getType()
69
    {
70
        return 'sampler';
71
    }
72
73
    /**
74
     * {@inheritdoc}
75
     */
76
    public function getArray()
77
    {
78
        $out = array_filter(
79
            [
80
                'field' => $this->getField(),
81
                'shard_size' => $this->getShardSize(),
82
            ]
83
        );
84
85
        return $out;
86
    }
87
}
88