Completed
Push — v0.10 ( f42b97...309689 )
by Simonas
8s
created

GeoBoundsAggregation   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 50
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A isWrapLongitude() 0 4 1
A setWrapLongitude() 0 4 1
A getType() 0 4 1
A getArray() 0 13 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\BucketingTrait;
15
16
/**
17
 * Class representing geo bounds aggregation.
18
 */
19
class GeoBoundsAggregation extends AbstractAggregation
20
{
21
    use BucketingTrait;
22
23
    /**
24
     * @var bool
25
     */
26
    private $wrapLongitude = true;
27
28
    /**
29
     * @return bool
30
     */
31
    public function isWrapLongitude()
32
    {
33
        return $this->wrapLongitude;
34
    }
35
36
    /**
37
     * @param bool $wrapLongitude
38
     */
39
    public function setWrapLongitude($wrapLongitude)
40
    {
41
        $this->wrapLongitude = $wrapLongitude;
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47
    public function getArray()
48
    {
49
        $data = [];
50
        if ($this->getField()) {
51
            $data['field'] = $this->getField();
52
        } else {
53
            throw new \LogicException('Geo bounds aggregation must have a field set.');
54
        }
55
56
        $data['wrap_longitude'] = $this->isWrapLongitude();
57
58
        return $data;
59
    }
60
61
    /**
62
     * {@inheritdoc}
63
     */
64
    public function getType()
65
    {
66
        return 'geo_bounds';
67
    }
68
}
69