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 — symbol ( 74f22f )
by Eric
63:49
created

SymbolCollector   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 75
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 5
dl 0
loc 75
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getMarkerCollector() 0 4 1
A setMarkerCollector() 0 4 1
A getIconSequenceCollector() 0 4 1
A setIconSequenceCollector() 0 4 1
A collect() 0 14 4
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
    public function __construct(MarkerCollector $markerCollector, IconSequenceCollector $iconSequenceCollector)
38
    {
39
        $this->setMarkerCollector($markerCollector);
40
        $this->setIconSequenceCollector($iconSequenceCollector);
41
    }
42
43
    /**
44
     * @return MarkerCollector
45
     */
46
    public function getMarkerCollector()
47
    {
48
        return $this->markerCollector;
49
    }
50
51
    /**
52
     * @param MarkerCollector $markerCollector
53
     */
54
    public function setMarkerCollector(MarkerCollector $markerCollector)
55
    {
56
        $this->markerCollector = $markerCollector;
57
    }
58
59
    /**
60
     * @return IconSequenceCollector
61
     */
62
    public function getIconSequenceCollector()
63
    {
64
        return $this->iconSequenceCollector;
65
    }
66
67
    /**
68
     * @param IconSequenceCollector $iconSequenceCollector
69
     */
70
    public function setIconSequenceCollector(IconSequenceCollector $iconSequenceCollector)
71
    {
72
        $this->iconSequenceCollector = $iconSequenceCollector;
73
    }
74
75
    /**
76
     * @param Map      $map
77
     * @param Symbol[] $symbols
78
     *
79
     * @return Symbol[]
80
     */
81
    public function collect(Map $map, array $symbols = [])
82
    {
83
        foreach ($this->markerCollector->collect($map) as $marker) {
84
            if ($marker->hasSymbol()) {
85
                $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
            }
87
        }
88
89
        foreach ($this->iconSequenceCollector->collect($map) as $icon) {
90
            $symbols = $this->collectValue($icon->getSymbol(), $symbols);
91
        }
92
93
        return $symbols;
94
    }
95
}
96