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\Size; |
15
|
|
|
use Ivory\GoogleMap\Helper\Collector\AbstractCollector; |
16
|
|
|
use Ivory\GoogleMap\Helper\Collector\Overlay\IconCollector; |
17
|
|
|
use Ivory\GoogleMap\Helper\Collector\Overlay\InfoWindowCollector; |
18
|
|
|
use Ivory\GoogleMap\Map; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @author GeLo <[email protected]> |
22
|
|
|
*/ |
23
|
|
|
class SizeCollector extends AbstractCollector |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* @var InfoWindowCollector |
27
|
|
|
*/ |
28
|
|
|
private $infoWindowCollector; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var IconCollector |
32
|
|
|
*/ |
33
|
|
|
private $iconCollector; |
34
|
|
|
|
35
|
24 |
|
public function __construct(InfoWindowCollector $infoWindowCollector, IconCollector $iconCollector) |
36
|
|
|
{ |
37
|
24 |
|
$this->setInfoWindowCollector($infoWindowCollector); |
38
|
24 |
|
$this->setIconCollector($iconCollector); |
39
|
24 |
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @return InfoWindowCollector |
43
|
|
|
*/ |
44
|
4 |
|
public function getInfoWindowCollector() |
45
|
|
|
{ |
46
|
4 |
|
return $this->infoWindowCollector; |
47
|
|
|
} |
48
|
|
|
|
49
|
24 |
|
public function setInfoWindowCollector(InfoWindowCollector $infoWindowCollector) |
50
|
|
|
{ |
51
|
24 |
|
$this->infoWindowCollector = $infoWindowCollector; |
52
|
24 |
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @return IconCollector |
56
|
|
|
*/ |
57
|
4 |
|
public function getIconCollector() |
58
|
|
|
{ |
59
|
4 |
|
return $this->iconCollector; |
60
|
|
|
} |
61
|
|
|
|
62
|
24 |
|
public function setIconCollector(IconCollector $iconCollector) |
63
|
|
|
{ |
64
|
24 |
|
$this->iconCollector = $iconCollector; |
65
|
24 |
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @param Size[] $sizes |
69
|
|
|
* |
70
|
|
|
* @return Size[] |
71
|
|
|
*/ |
72
|
12 |
|
public function collect(Map $map, array $sizes = []) |
73
|
|
|
{ |
74
|
12 |
|
foreach ($this->infoWindowCollector->collect($map) as $infoWindow) { |
75
|
4 |
|
if ($infoWindow->hasPixelOffset()) { |
76
|
4 |
|
$sizes = $this->collectValue($infoWindow->getPixelOffset(), $sizes); |
|
|
|
|
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|
80
|
12 |
|
foreach ($this->iconCollector->collect($map) as $icon) { |
81
|
4 |
|
if ($icon->hasSize()) { |
82
|
4 |
|
$sizes = $this->collectValue($icon->getSize(), $sizes); |
83
|
|
|
} |
84
|
|
|
|
85
|
4 |
|
if ($icon->hasScaledSize()) { |
86
|
4 |
|
$sizes = $this->collectValue($icon->getScaledSize(), $sizes); |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|
90
|
12 |
|
return $sizes; |
91
|
|
|
} |
92
|
|
|
} |
93
|
|
|
|
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: