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

CoordinateCollector::getHeatmapLayerCollector()   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 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\Helper\Collector\Base;
13
14
use Ivory\GoogleMap\Base\Coordinate;
15
use Ivory\GoogleMap\Helper\Collector\AbstractCollector;
16
use Ivory\GoogleMap\Helper\Collector\Layer\HeatmapLayerCollector;
17
use Ivory\GoogleMap\Helper\Collector\Overlay\CircleCollector;
18
use Ivory\GoogleMap\Helper\Collector\Overlay\InfoWindowCollector;
19
use Ivory\GoogleMap\Helper\Collector\Overlay\MarkerCollector;
20
use Ivory\GoogleMap\Helper\Collector\Overlay\PolygonCollector;
21
use Ivory\GoogleMap\Helper\Collector\Overlay\PolylineCollector;
22
use Ivory\GoogleMap\Map;
23
24
/**
25
 * @author GeLo <[email protected]>
26
 */
27
class CoordinateCollector extends AbstractCollector
28
{
29
    /**
30
     * @var BoundCollector
31
     */
32
    private $boundCollector;
33
34
    /**
35
     * @var CircleCollector
36
     */
37
    private $circleCollector;
38
39
    /**
40
     * @var InfoWindowCollector
41
     */
42
    private $infoWindowCollector;
43
44
    /**
45
     * @var MarkerCollector
46
     */
47
    private $markerCollector;
48
49
    /**
50
     * @var PolygonCollector
51
     */
52
    private $polygonCollector;
53
54
    /**
55
     * @var PolylineCollector
56
     */
57
    private $polylineCollector;
58
59
    /**
60
     * @var HeatmapLayerCollector
61
     */
62
    private $heatmapLayerCollector;
63
64
    /**
65
     * @param BoundCollector        $boundCollector
66
     * @param CircleCollector       $circleCollector
67
     * @param InfoWindowCollector   $infoWindowCollector
68
     * @param MarkerCollector       $markerCollector
69
     * @param PolygonCollector      $polygonCollector
70
     * @param PolylineCollector     $polylineCollector
71
     * @param HeatmapLayerCollector $heatmapLayerCollector
72
     */
73
    public function __construct(
74
        BoundCollector $boundCollector,
75
        CircleCollector $circleCollector,
76
        InfoWindowCollector $infoWindowCollector,
77
        MarkerCollector $markerCollector,
78
        PolygonCollector $polygonCollector,
79
        PolylineCollector $polylineCollector,
80
        HeatmapLayerCollector $heatmapLayerCollector
81
    ) {
82
        $this->setBoundCollector($boundCollector);
83
        $this->setCircleCollector($circleCollector);
84
        $this->setInfoWindowCollector($infoWindowCollector);
85
        $this->setMarkerCollector($markerCollector);
86
        $this->setPolygonCollector($polygonCollector);
87
        $this->setPolylineCollector($polylineCollector);
88
        $this->setHeatmapLayerCollector($heatmapLayerCollector);
89
    }
90
91
    /**
92
     * @return BoundCollector
93
     */
94
    public function getBoundCollector()
95
    {
96
        return $this->boundCollector;
97
    }
98
99
    /**
100
     * @param BoundCollector $boundCollector
101
     */
102
    public function setBoundCollector(BoundCollector $boundCollector)
103
    {
104
        $this->boundCollector = $boundCollector;
105
    }
106
107
    /**
108
     * @return CircleCollector
109
     */
110
    public function getCircleCollector()
111
    {
112
        return $this->circleCollector;
113
    }
114
115
    /**
116
     * @param CircleCollector $circleCollector
117
     */
118
    public function setCircleCollector(CircleCollector $circleCollector)
119
    {
120
        $this->circleCollector = $circleCollector;
121
    }
122
123
    /**
124
     * @return InfoWindowCollector
125
     */
126
    public function getInfoWindowCollector()
127
    {
128
        return $this->infoWindowCollector;
129
    }
130
131
    /**
132
     * @param InfoWindowCollector $infoWindowCollector
133
     */
134
    public function setInfoWindowCollector(InfoWindowCollector $infoWindowCollector)
135
    {
136
        $this->infoWindowCollector = $infoWindowCollector;
137
    }
138
139
    /**
140
     * @return MarkerCollector
141
     */
142
    public function getMarkerCollector()
143
    {
144
        return $this->markerCollector;
145
    }
146
147
    /**
148
     * @param MarkerCollector $markerCollector
149
     */
150
    public function setMarkerCollector(MarkerCollector $markerCollector)
151
    {
152
        $this->markerCollector = $markerCollector;
153
    }
154
155
    /**
156
     * @return PolygonCollector
157
     */
158
    public function getPolygonCollector()
159
    {
160
        return $this->polygonCollector;
161
    }
162
163
    /**
164
     * @param PolygonCollector $polygonCollector
165
     */
166
    public function setPolygonCollector(PolygonCollector $polygonCollector)
167
    {
168
        $this->polygonCollector = $polygonCollector;
169
    }
170
171
    /**
172
     * @return PolylineCollector
173
     */
174
    public function getPolylineCollector()
175
    {
176
        return $this->polylineCollector;
177
    }
178
179
    /**
180
     * @param PolylineCollector $polylineCollector
181
     */
182
    public function setPolylineCollector(PolylineCollector $polylineCollector)
183
    {
184
        $this->polylineCollector = $polylineCollector;
185
    }
186
187
    /**
188
     * @return HeatmapLayerCollector
189
     */
190
    public function getHeatmapLayerCollector()
191
    {
192
        return $this->heatmapLayerCollector;
193
    }
194
195
    /**
196
     * @param HeatmapLayerCollector $heatmapLayerCollector
197
     */
198
    public function setHeatmapLayerCollector(HeatmapLayerCollector $heatmapLayerCollector)
199
    {
200
        $this->heatmapLayerCollector = $heatmapLayerCollector;
201
    }
202
203
    /**
204
     * @param Map          $map
205
     * @param Coordinate[] $coordinates
206
     *
207
     * @return Coordinate[]
208
     */
209
    public function collect(Map $map, array $coordinates = [])
210
    {
211
        if (!$map->isAutoZoom()) {
212
            $coordinates = $this->collectValue($map->getCenter(), $coordinates);
213
        }
214
215 View Code Duplication
        foreach ($this->boundCollector->collect($map) as $bound) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
216
            if ($bound->hasCoordinates()) {
217
                $coordinates = $this->collectValue($bound->getSouthWest(), $coordinates);
218
                $coordinates = $this->collectValue($bound->getNorthEast(), $coordinates);
219
            }
220
        }
221
222
        foreach ($this->circleCollector->collect($map) as $circle) {
223
            $coordinates = $this->collectValue($circle->getCenter(), $coordinates);
224
        }
225
226
        foreach ($this->infoWindowCollector->collect($map) as $infoWindow) {
227
            if ($infoWindow->hasPosition()) {
228
                $coordinates = $this->collectValue($infoWindow->getPosition(), $coordinates);
0 ignored issues
show
Bug introduced by
It seems like $infoWindow->getPosition() can be null; however, collectValue() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
229
            }
230
        }
231
232
        foreach ($this->markerCollector->collect($map) as $marker) {
233
            $coordinates = $this->collectValue($marker->getPosition(), $coordinates);
234
        }
235
236
        foreach ($this->polygonCollector->collect($map) as $polygon) {
237
            $coordinates = $this->collectValues($polygon->getCoordinates(), $coordinates);
238
        }
239
240
        foreach ($this->polylineCollector->collect($map) as $polyline) {
241
            $coordinates = $this->collectValues($polyline->getCoordinates(), $coordinates);
242
        }
243
244
        foreach ($this->heatmapLayerCollector->collect($map) as $heatmapLayer) {
245
            $coordinates = $this->collectValues($heatmapLayer->getCoordinates(), $coordinates);
246
        }
247
248
        return $coordinates;
249
    }
250
}
251