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.

SizeCollector::getIconCollector()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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\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
    /**
36
     * @param InfoWindowCollector $infoWindowCollector
37
     * @param IconCollector       $iconCollector
38
     */
39 240
    public function __construct(InfoWindowCollector $infoWindowCollector, IconCollector $iconCollector)
40
    {
41 240
        $this->setInfoWindowCollector($infoWindowCollector);
42 240
        $this->setIconCollector($iconCollector);
43 240
    }
44
45
    /**
46
     * @return InfoWindowCollector
47
     */
48 4
    public function getInfoWindowCollector()
49
    {
50 4
        return $this->infoWindowCollector;
51
    }
52
53
    /**
54
     * @param InfoWindowCollector $infoWindowCollector
55
     */
56 240
    public function setInfoWindowCollector(InfoWindowCollector $infoWindowCollector)
57
    {
58 240
        $this->infoWindowCollector = $infoWindowCollector;
59 240
    }
60
61
    /**
62
     * @return IconCollector
63
     */
64 4
    public function getIconCollector()
65
    {
66 4
        return $this->iconCollector;
67
    }
68
69
    /**
70
     * @param IconCollector $iconCollector
71
     */
72 240
    public function setIconCollector(IconCollector $iconCollector)
73
    {
74 240
        $this->iconCollector = $iconCollector;
75 240
    }
76
77
    /**
78
     * @param Map    $map
79
     * @param Size[] $sizes
80
     *
81
     * @return Size[]
82
     */
83 228
    public function collect(Map $map, array $sizes = [])
84
    {
85 228
        foreach ($this->infoWindowCollector->collect($map) as $infoWindow) {
86 52
            if ($infoWindow->hasPixelOffset()) {
87 32
                $sizes = $this->collectValue($infoWindow->getPixelOffset(), $sizes);
0 ignored issues
show
Bug introduced by
It seems like $infoWindow->getPixelOffset() 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...
88 6
            }
89 114
        }
90
91 228
        foreach ($this->iconCollector->collect($map) as $icon) {
92 12
            if ($icon->hasSize()) {
93 4
                $sizes = $this->collectValue($icon->getSize(), $sizes);
94 2
            }
95
96 12
            if ($icon->hasScaledSize()) {
97 8
                $sizes = $this->collectValue($icon->getScaledSize(), $sizes);
98 2
            }
99 114
        }
100
101 228
        return $sizes;
102
    }
103
}
104