GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — heatmap-layer ( 9858f3 )
by Eric
02:46
created

HeatmapLayer::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 6
rs 9.4285
cc 1
eloc 4
nc 1
nop 2
1
<?php
2
3
/*
4
 * This file is part of the Ivory Google Map package.
5
 *
6
 * (c) Eric GELOEN <[email protected]>
7
 *
8
 * For the full copyright and license information, please read the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Ivory\GoogleMap\Layer;
13
14
use Ivory\GoogleMap\Base\Coordinate;
15
use Ivory\GoogleMap\Utility\OptionsAwareInterface;
16
use Ivory\GoogleMap\Utility\OptionsAwareTrait;
17
use Ivory\GoogleMap\Utility\VariableAwareInterface;
18
use Ivory\GoogleMap\Utility\VariableAwareTrait;
19
20
/**
21
 * @author GeLo <[email protected]>
22
 */
23
class HeatmapLayer implements OptionsAwareInterface, VariableAwareInterface
24
{
25
    use OptionsAwareTrait;
26
    use VariableAwareTrait;
27
28
    /**
29
     * @var Coordinate[]
30
     */
31
    private $coordinates = [];
32
33
    /**
34
     * @param Coordinate[] $coordinates
35
     * @param mixed[]      $options
36
     */
37
    public function __construct(array $coordinates = [], array $options = [])
38
    {
39
        $this->setVariablePrefix('heatmap_layer');
40
        $this->setCoordinates($coordinates);
41
        $this->setOptions($options);
42
    }
43
44
    /**
45
     * @return bool
46
     */
47
    public function hasCoordinates()
48
    {
49
        return !empty($this->coordinates);
50
    }
51
52
    /**
53
     * @return Coordinate[]
54
     */
55
    public function getCoordinates()
56
    {
57
        return $this->coordinates;
58
    }
59
60
    /**
61
     * @param Coordinate[] $coordinates
62
     */
63
    public function setCoordinates(array $coordinates)
64
    {
65
        $this->coordinates = [];
66
        $this->addCoordinates($coordinates);
67
    }
68
69
    /**
70
     * @param Coordinate[] $coordinates
71
     */
72
    public function addCoordinates(array $coordinates)
73
    {
74
        foreach ($coordinates as $coordinate) {
75
            $this->addCoordinate($coordinate);
76
        }
77
    }
78
79
    /**
80
     * @param Coordinate $coordinate
81
     *
82
     * @return bool
83
     */
84
    public function hasCoordinate(Coordinate $coordinate)
85
    {
86
        return in_array($coordinate, $this->coordinates, true);
87
    }
88
89
    /**
90
     * @param Coordinate $coordinate
91
     */
92
    public function addCoordinate(Coordinate $coordinate)
93
    {
94
        if (!$this->hasCoordinate($coordinate)) {
95
            $this->coordinates[] = $coordinate;
96
        }
97
    }
98
99
    /**
100
     * @param Coordinate $coordinate
101
     */
102
    public function removeCoordinate(Coordinate $coordinate)
103
    {
104
        unset($this->coordinates[array_search($coordinate, $this->coordinates, true)]);
105
        $this->coordinates = array_values($this->coordinates);
106
    }
107
}
108