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.

InfoWindowCollector::setMarkerCollector()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
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\Overlay;
13
14
use Ivory\GoogleMap\Helper\Collector\AbstractCollector;
15
use Ivory\GoogleMap\Map;
16
use Ivory\GoogleMap\Overlay\InfoWindow;
17
18
/**
19
 * @author GeLo <[email protected]>
20
 */
21
class InfoWindowCollector extends AbstractCollector
22
{
23
    const STRATEGY_MAP = 1;
24
    const STRATEGY_MARKER = 2;
25
26
    /**
27
     * @var MarkerCollector
28
     */
29
    private $markerCollector;
30
31
    /**
32
     * @var string|null
33
     */
34
    private $type;
35
36
    /**
37
     * @param MarkerCollector $markerCollector
38
     * @param string|null     $type
39
     */
40 404
    public function __construct(MarkerCollector $markerCollector, $type = null)
41
    {
42 404
        $this->setMarkerCollector($markerCollector);
43 404
        $this->setType($type);
44 404
    }
45
46
    /**
47
     * @return MarkerCollector
48
     */
49 4
    public function getMarkerCollector()
50
    {
51 4
        return $this->markerCollector;
52
    }
53
54
    /**
55
     * @param MarkerCollector $markerCollector
56
     */
57 404
    public function setMarkerCollector(MarkerCollector $markerCollector)
58
    {
59 404
        $this->markerCollector = $markerCollector;
60 404
    }
61
62
    /**
63
     * @return string|null
64
     */
65 12
    public function getType()
66
    {
67 12
        return $this->type;
68
    }
69
70
    /**
71
     * @param string|null $type
72
     */
73 404
    public function setType($type)
74
    {
75 404
        $this->type = $type;
76 404
    }
77
78
    /**
79
     * @param Map          $map
80
     * @param InfoWindow[] $infoWindows
81
     * @param int|null     $strategy
82
     *
83
     * @return InfoWindow[]
84
     */
85 300
    public function collect(Map $map, array $infoWindows = [], $strategy = null)
86
    {
87 300
        if ($strategy === null) {
88 264
            $strategy = self::STRATEGY_MAP | self::STRATEGY_MARKER;
89 132
        }
90
91 300
        if ($strategy & self::STRATEGY_MAP) {
92 288
            $infoWindows = $this->collectValues($map->getOverlayManager()->getInfoWindows(), $infoWindows);
93 144
        }
94
95 300
        if ($strategy & self::STRATEGY_MARKER) {
96 288
            foreach ($this->markerCollector->collect($map) as $marker) {
97 80
                if ($marker->hasInfoWindow()) {
98 60
                    $infoWindows = $this->collectValue($marker->getInfoWindow(), $infoWindows);
99 20
                }
100 144
            }
101 144
        }
102
103 300
        return $infoWindows;
104
    }
105
106
    /**
107
     * {@inheritdoc}
108
     */
109 92
    protected function collectValue($value, array $defaults = [])
110
    {
111 92
        if ($this->type !== null && $value->getType() !== $this->type) {
112 72
            return $defaults;
113
        }
114
115 92
        return parent::collectValue($value, $defaults);
116
    }
117
}
118