Passed
Push — feature/v4 ( e5e380...dac4aa )
by Samuel
11:37
created

CoordinateCollector::setCircleCollector()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Ivory Google Map package.
7
 *
8
 * (c) Eric GELOEN <[email protected]>
9
 *
10
 * For the full copyright and license information, please read the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Ivory\GoogleMap\Helper\Collector\Base;
15
16
use Ivory\GoogleMap\Base\Coordinate;
17
use Ivory\GoogleMap\Helper\Collector\AbstractCollector;
18
use Ivory\GoogleMap\Helper\Collector\Layer\HeatmapLayerCollector;
19
use Ivory\GoogleMap\Helper\Collector\Overlay\CircleCollector;
20
use Ivory\GoogleMap\Helper\Collector\Overlay\InfoWindowCollector;
21
use Ivory\GoogleMap\Helper\Collector\Overlay\MarkerCollector;
22
use Ivory\GoogleMap\Helper\Collector\Overlay\PolygonCollector;
23
use Ivory\GoogleMap\Helper\Collector\Overlay\PolylineCollector;
24
use Ivory\GoogleMap\Map;
25
26
class CoordinateCollector extends AbstractCollector
27
{
28
    /** @var BoundCollector */
29
    private $boundCollector;
30
31
    /** @var CircleCollector */
32
    private $circleCollector;
33
34
    /** @var InfoWindowCollector */
35
    private $infoWindowCollector;
36
37
    /** @var MarkerCollector */
38
    private $markerCollector;
39
40
    /** @var PolygonCollector */
41
    private $polygonCollector;
42
43
    /** @var PolylineCollector */
44
    private $polylineCollector;
45
46
    /** @var HeatmapLayerCollector */
47
    private $heatmapLayerCollector;
48
49 17
    public function __construct(
50
        BoundCollector $boundCollector,
51
        CircleCollector $circleCollector,
52
        InfoWindowCollector $infoWindowCollector,
53
        MarkerCollector $markerCollector,
54
        PolygonCollector $polygonCollector,
55
        PolylineCollector $polylineCollector,
56
        HeatmapLayerCollector $heatmapLayerCollector
57
    ) {
58 17
        $this->setBoundCollector($boundCollector);
59 17
        $this->setCircleCollector($circleCollector);
60 17
        $this->setInfoWindowCollector($infoWindowCollector);
61 17
        $this->setMarkerCollector($markerCollector);
62 17
        $this->setPolygonCollector($polygonCollector);
63 17
        $this->setPolylineCollector($polylineCollector);
64 17
        $this->setHeatmapLayerCollector($heatmapLayerCollector);
65 17
    }
66
67 1
    public function getBoundCollector(): BoundCollector
68
    {
69 1
        return $this->boundCollector;
70
    }
71
72 17
    public function setBoundCollector(BoundCollector $boundCollector): void
73
    {
74 17
        $this->boundCollector = $boundCollector;
75 17
    }
76
77 1
    public function getCircleCollector(): CircleCollector
78
    {
79 1
        return $this->circleCollector;
80
    }
81
82 17
    public function setCircleCollector(CircleCollector $circleCollector): void
83
    {
84 17
        $this->circleCollector = $circleCollector;
85 17
    }
86
87 1
    public function getInfoWindowCollector(): InfoWindowCollector
88
    {
89 1
        return $this->infoWindowCollector;
90
    }
91
92 17
    public function setInfoWindowCollector(InfoWindowCollector $infoWindowCollector): void
93
    {
94 17
        $this->infoWindowCollector = $infoWindowCollector;
95 17
    }
96
97 1
    public function getMarkerCollector(): MarkerCollector
98
    {
99 1
        return $this->markerCollector;
100
    }
101
102 17
    public function setMarkerCollector(MarkerCollector $markerCollector): void
103
    {
104 17
        $this->markerCollector = $markerCollector;
105 17
    }
106
107 1
    public function getPolygonCollector(): PolygonCollector
108
    {
109 1
        return $this->polygonCollector;
110
    }
111
112 17
    public function setPolygonCollector(PolygonCollector $polygonCollector): void
113
    {
114 17
        $this->polygonCollector = $polygonCollector;
115 17
    }
116
117 1
    public function getPolylineCollector(): PolylineCollector
118
    {
119 1
        return $this->polylineCollector;
120
    }
121
122 17
    public function setPolylineCollector(PolylineCollector $polylineCollector): void
123
    {
124 17
        $this->polylineCollector = $polylineCollector;
125 17
    }
126
127 1
    public function getHeatmapLayerCollector(): HeatmapLayerCollector
128
    {
129 1
        return $this->heatmapLayerCollector;
130
    }
131
132 17
    public function setHeatmapLayerCollector(HeatmapLayerCollector $heatmapLayerCollector): void
133
    {
134 17
        $this->heatmapLayerCollector = $heatmapLayerCollector;
135 17
    }
136
137
    /**
138
     * @param Coordinate[] $coordinates
139
     *
140
     * @return Coordinate[]
141
     */
142 9
    public function collect(Map $map, array $coordinates = []): array
143
    {
144 9
        if (!$map->isAutoZoom()) {
145 8
            $coordinates = $this->collectValue($map->getCenter(), $coordinates);
146
        }
147
148 9
        foreach ($this->boundCollector->collect($map) as $bound) {
149 2
            if ($bound->hasCoordinates()) {
150 1
                $coordinates = $this->collectValue($bound->getSouthWest(), $coordinates);
151 1
                $coordinates = $this->collectValue($bound->getNorthEast(), $coordinates);
152
            }
153
        }
154
155 9
        foreach ($this->circleCollector->collect($map) as $circle) {
156 1
            $coordinates = $this->collectValue($circle->getCenter(), $coordinates);
157
        }
158
159 9
        foreach ($this->infoWindowCollector->collect($map) as $infoWindow) {
160 1
            if ($infoWindow->hasPosition()) {
161 1
                $coordinates = $this->collectValue($infoWindow->getPosition(), $coordinates);
162
            }
163
        }
164
165 9
        foreach ($this->markerCollector->collect($map) as $marker) {
166 1
            $coordinates = $this->collectValue($marker->getPosition(), $coordinates);
167
        }
168
169 9
        foreach ($this->polygonCollector->collect($map) as $polygon) {
170 1
            $coordinates = $this->collectValues($polygon->getCoordinates(), $coordinates);
171
        }
172
173 9
        foreach ($this->polylineCollector->collect($map) as $polyline) {
174 1
            $coordinates = $this->collectValues($polyline->getCoordinates(), $coordinates);
175
        }
176
177 9
        foreach ($this->heatmapLayerCollector->collect($map) as $heatmapLayer) {
178 1
            $coordinates = $this->collectValues($heatmapLayer->getCoordinates(), $coordinates);
179
        }
180
181 9
        return $coordinates;
182
    }
183
}
184