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 — layer-auto-zoom ( 8bf3f7 )
by Eric
03:19
created

LayerManager   B

Complexity

Total Complexity 39

Size/Duplication

Total Lines 282
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Importance

Changes 5
Bugs 0 Features 3
Metric Value
wmc 39
c 5
b 0
f 3
lcom 2
cbo 1
dl 0
loc 282
rs 8.2857

27 Methods

Rating   Name   Duplication   Size   Complexity  
A hasMap() 0 4 1
A getMap() 0 4 1
A setMap() 0 8 2
A hasGeoJsonLayers() 0 4 1
A getGeoJsonLayers() 0 4 1
A setGeoJsonLayers() 0 5 1
A addGeoJsonLayers() 0 6 2
A hasGeoJsonLayer() 0 4 1
A addGeoJsonLayer() 0 6 2
A removeGeoJsonLayer() 0 5 1
A hasHeatmapLayers() 0 4 1
A getHeatmapLayers() 0 4 1
A setHeatmapLayers() 0 8 2
A addHeatmapLayers() 0 6 2
A hasHeatmapLayer() 0 4 1
A addHeatmapLayer() 0 8 2
A removeHeatmapLayer() 0 6 1
A hasKmlLayers() 0 4 1
A getKmlLayers() 0 4 1
A setKmlLayers() 0 8 2
A addKmlLayers() 0 6 2
A hasKmlLayer() 0 4 1
A addKmlLayer() 0 8 2
A removeKmlLayer() 0 6 1
A addExtendable() 0 6 2
A removeExtendable() 0 6 2
A isAutoZoom() 0 4 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\Map;
15
use Ivory\GoogleMap\Overlay\ExtendableInterface;
16
17
/**
18
 * @author GeLo <[email protected]>
19
 */
20
class LayerManager
21
{
22
    /**
23
     * @var Map|null
24
     */
25
    private $map;
26
27
    /**
28
     * @var GeoJsonLayer[]
29
     */
30
    private $geoJsonLayers = [];
31
32
    /**
33
     * @var HeatmapLayer[]
34
     */
35
    private $heatmapLayers = [];
36
37
    /**
38
     * @var KmlLayer[]
39
     */
40
    private $kmlLayers = [];
41
42
    /**
43
     * @return bool
44
     */
45
    public function hasMap()
46
    {
47
        return $this->map !== null;
48
    }
49
50
    /**
51
     * @return Map|null
52
     */
53
    public function getMap()
54
    {
55
        return $this->map;
56
    }
57
58
    /**
59
     * @param Map $map
60
     */
61
    public function setMap(Map $map)
62
    {
63
        $this->map = $map;
64
65
        if ($map->getLayerManager() !== $this) {
66
            $map->setLayerManager($this);
67
        }
68
    }
69
70
    /**
71
     * @return bool
72
     */
73
    public function hasGeoJsonLayers()
74
    {
75
        return !empty($this->geoJsonLayers);
76
    }
77
78
    /**
79
     * @return GeoJsonLayer[]
80
     */
81
    public function getGeoJsonLayers()
82
    {
83
        return $this->geoJsonLayers;
84
    }
85
86
    /**
87
     * @param GeoJsonLayer[] $geoJsonLayers
88
     */
89
    public function setGeoJsonLayers(array $geoJsonLayers)
90
    {
91
        $this->geoJsonLayers = [];
92
        $this->addGeoJsonLayers($geoJsonLayers);
93
    }
94
95
    /**
96
     * @param GeoJsonLayer[] $geoJsonLayers
97
     */
98
    public function addGeoJsonLayers(array $geoJsonLayers)
99
    {
100
        foreach ($geoJsonLayers as $geoJsonLayer) {
101
            $this->addGeoJsonLayer($geoJsonLayer);
102
        }
103
    }
104
105
    /**
106
     * @param GeoJsonLayer $geoJsonLayer
107
     *
108
     * @return bool
109
     */
110
    public function hasGeoJsonLayer(GeoJsonLayer $geoJsonLayer)
111
    {
112
        return in_array($geoJsonLayer, $this->geoJsonLayers, true);
113
    }
114
115
    /**
116
     * @param GeoJsonLayer $geoJsonLayer
117
     */
118
    public function addGeoJsonLayer(GeoJsonLayer $geoJsonLayer)
119
    {
120
        if (!$this->hasGeoJsonLayer($geoJsonLayer)) {
121
            $this->geoJsonLayers[] = $geoJsonLayer;
122
        }
123
    }
124
125
    /**
126
     * @param GeoJsonLayer $geoJsonLayer
127
     */
128
    public function removeGeoJsonLayer(GeoJsonLayer $geoJsonLayer)
129
    {
130
        unset($this->geoJsonLayers[array_search($geoJsonLayer, $this->geoJsonLayers, true)]);
131
        $this->geoJsonLayers = array_values($this->geoJsonLayers);
132
    }
133
134
    /**
135
     * @return bool
136
     */
137
    public function hasHeatmapLayers()
138
    {
139
        return !empty($this->heatmapLayers);
140
    }
141
142
    /**
143
     * @return HeatmapLayer[]
144
     */
145
    public function getHeatmapLayers()
146
    {
147
        return $this->heatmapLayers;
148
    }
149
150
    /**
151
     * @param HeatmapLayer[] $heatmapLayers
152
     */
153
    public function setHeatmapLayers(array $heatmapLayers)
154
    {
155
        foreach ($this->heatmapLayers as $heatmapLayer) {
156
            $this->removeHeatmapLayer($heatmapLayer);
157
        }
158
159
        $this->addHeatmapLayers($heatmapLayers);
160
    }
161
162
    /**
163
     * @param HeatmapLayer[] $heatmapLayers
164
     */
165
    public function addHeatmapLayers(array $heatmapLayers)
166
    {
167
        foreach ($heatmapLayers as $heatmapLayer) {
168
            $this->addHeatmapLayer($heatmapLayer);
169
        }
170
    }
171
172
    /**
173
     * @param HeatmapLayer $heatmapLayer
174
     *
175
     * @return bool
176
     */
177
    public function hasHeatmapLayer(HeatmapLayer $heatmapLayer)
178
    {
179
        return in_array($heatmapLayer, $this->heatmapLayers, true);
180
    }
181
182
    /**
183
     * @param HeatmapLayer $heatmapLayer
184
     */
185
    public function addHeatmapLayer(HeatmapLayer $heatmapLayer)
186
    {
187
        if (!$this->hasHeatmapLayer($heatmapLayer)) {
188
            $this->heatmapLayers[] = $heatmapLayer;
189
        }
190
191
        $this->addExtendable($heatmapLayer);
192
    }
193
194
    /**
195
     * @param HeatmapLayer $heatmapLayer
196
     */
197
    public function removeHeatmapLayer(HeatmapLayer $heatmapLayer)
198
    {
199
        unset($this->heatmapLayers[array_search($heatmapLayer, $this->heatmapLayers, true)]);
200
        $this->heatmapLayers = array_values($this->heatmapLayers);
201
        $this->removeExtendable($heatmapLayer);
202
    }
203
204
    /**
205
     * @return bool
206
     */
207
    public function hasKmlLayers()
208
    {
209
        return !empty($this->kmlLayers);
210
    }
211
212
    /**
213
     * @return KmlLayer[]
214
     */
215
    public function getKmlLayers()
216
    {
217
        return $this->kmlLayers;
218
    }
219
220
    /**
221
     * @param KmlLayer[] $kmlLayers
222
     */
223
    public function setKmlLayers(array $kmlLayers)
224
    {
225
        foreach ($this->kmlLayers as $kmlLayer) {
226
            $this->removeKmlLayer($kmlLayer);
227
        }
228
229
        $this->addKmlLayers($kmlLayers);
230
    }
231
232
    /**
233
     * @param KmlLayer[] $kmlLayers
234
     */
235
    public function addKmlLayers(array $kmlLayers)
236
    {
237
        foreach ($kmlLayers as $kmlLayer) {
238
            $this->addKmlLayer($kmlLayer);
239
        }
240
    }
241
242
    /**
243
     * @param KmlLayer $kmlLayer
244
     *
245
     * @return bool
246
     */
247
    public function hasKmlLayer(KmlLayer $kmlLayer)
248
    {
249
        return in_array($kmlLayer, $this->kmlLayers, true);
250
    }
251
252
    /**
253
     * @param KmlLayer $kmlLayer
254
     */
255
    public function addKmlLayer(KmlLayer $kmlLayer)
256
    {
257
        if (!$this->hasKmlLayer($kmlLayer)) {
258
            $this->kmlLayers[] = $kmlLayer;
259
        }
260
261
        $this->addExtendable($kmlLayer);
262
    }
263
264
    /**
265
     * @param KmlLayer $kmlLayer
266
     */
267
    public function removeKmlLayer(KmlLayer $kmlLayer)
268
    {
269
        unset($this->kmlLayers[array_search($kmlLayer, $this->kmlLayers, true)]);
270
        $this->kmlLayers = array_values($this->kmlLayers);
271
        $this->removeExtendable($kmlLayer);
272
    }
273
274
    /**
275
     * @param ExtendableInterface $extendable
276
     */
277
    private function addExtendable(ExtendableInterface $extendable)
278
    {
279
        if ($this->isAutoZoom()) {
280
            $this->getMap()->getBound()->addExtendable($extendable);
281
        }
282
    }
283
284
    /**
285
     * @param ExtendableInterface $extendable
286
     */
287
    private function removeExtendable(ExtendableInterface $extendable)
288
    {
289
        if ($this->isAutoZoom()) {
290
            $this->getMap()->getBound()->removeExtendable($extendable);
291
        }
292
    }
293
294
    /**
295
     * @return bool
296
     */
297
    private function isAutoZoom()
298
    {
299
        return $this->hasMap() && $this->getMap()->isAutoZoom();
300
    }
301
}
302