Completed
Pull Request — master (#1880)
by
unknown
02:29
created

GeotileGridAggregation::setSize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Elastica\Aggregation;
4
5
/**
6
 * Class GeotileGridAggregation.
7
 *
8
 * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-geotilegrid-aggregation.html
9
 */
10
class GeotileGridAggregation extends AbstractAggregation
11
{
12
    use Traits\ShardSizeTrait;
13
14
    /**
15
     * @param string $name  the name of this aggregation
16
     * @param string $field the field on which to perform this aggregation
17
     */
18
    public function __construct(string $name, string $field)
19
    {
20
        parent::__construct($name);
21
        $this->setField($field);
22
    }
23
24
    /**
25
     * Set the field for this aggregation.
26
     *
27
     * @param string $field the name of the document field on which to perform this aggregation
28
     *
29
     * @return $this
30
     */
31
    public function setField(string $field): self
32
    {
33
        return $this->setParam('field', $field);
34
    }
35
36
    /**
37
     * Set the precision for this aggregation.
38
     *
39
     * @param int $precision an integer between 1 and 12, inclusive. Defaults to 5.
40
     *
41
     * @return $this
42
     */
43
    public function setPrecision(int $precision): self
44
    {
45
        return $this->setParam('precision', $precision);
46
    }
47
48
    /**
49
     * Set the maximum number of buckets to return.
50
     *
51
     * @param int $size defaults to 10,000
52
     *
53
     * @return $this
54
     */
55
    public function setSize(int $size): self
56
    {
57
        return $this->setParam('size', $size);
58
    }
59
}
60