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 — master ( f79bcb...de7e43 )
by Eric
80:29 queued 77:22
created

SymbolCollector::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
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\Symbol;
17
18
/**
19
 * @author GeLo <[email protected]>
20
 */
21
class SymbolCollector extends AbstractCollector
22
{
23
    /**
24
     * @var MarkerCollector
25
     */
26
    private $markerCollector;
27
28
    /**
29
     * @var IconSequenceCollector
30
     */
31
    private $iconSequenceCollector;
32
33
    /**
34
     * @param MarkerCollector       $markerCollector
35
     * @param IconSequenceCollector $iconSequenceCollector
36
     */
37 236
    public function __construct(MarkerCollector $markerCollector, IconSequenceCollector $iconSequenceCollector)
38
    {
39 236
        $this->setMarkerCollector($markerCollector);
40 236
        $this->setIconSequenceCollector($iconSequenceCollector);
41 236
    }
42
43
    /**
44
     * @return MarkerCollector
45
     */
46 4
    public function getMarkerCollector()
47
    {
48 4
        return $this->markerCollector;
49
    }
50
51
    /**
52
     * @param MarkerCollector $markerCollector
53
     */
54 236
    public function setMarkerCollector(MarkerCollector $markerCollector)
55
    {
56 236
        $this->markerCollector = $markerCollector;
57 236
    }
58
59
    /**
60
     * @return IconSequenceCollector
61
     */
62 4
    public function getIconSequenceCollector()
63
    {
64 4
        return $this->iconSequenceCollector;
65
    }
66
67
    /**
68
     * @param IconSequenceCollector $iconSequenceCollector
69
     */
70 236
    public function setIconSequenceCollector(IconSequenceCollector $iconSequenceCollector)
71
    {
72 236
        $this->iconSequenceCollector = $iconSequenceCollector;
73 236
    }
74
75
    /**
76
     * @param Map      $map
77
     * @param Symbol[] $symbols
78
     *
79
     * @return Symbol[]
80
     */
81 224
    public function collect(Map $map, array $symbols = [])
82
    {
83 224
        foreach ($this->markerCollector->collect($map) as $marker) {
84 52
            if ($marker->hasSymbol()) {
85 30
                $symbols = $this->collectValue($marker->getSymbol(), $symbols);
0 ignored issues
show
Bug introduced by
It seems like $marker->getSymbol() 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...
86 4
            }
87 112
        }
88
89 224
        foreach ($this->iconSequenceCollector->collect($map) as $icon) {
90 8
            $symbols = $this->collectValue($icon->getSymbol(), $symbols);
91 112
        }
92
93 224
        return $symbols;
94
    }
95
}
96