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

MarkerShapeCollector::collect()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 10
Ratio 100 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 0
Metric Value
dl 10
loc 10
ccs 7
cts 7
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 5
nc 3
nop 2
crap 3
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\MarkerShape;
17
18
/**
19
 * @author GeLo <[email protected]>
20
 */
21 View Code Duplication
class MarkerShapeCollector extends AbstractCollector
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
22
{
23
    /**
24
     * @var MarkerCollector
25
     */
26
    private $markerCollector;
27
28
    /**
29
     * @param MarkerCollector $markerCollector
30
     */
31 232
    public function __construct(MarkerCollector $markerCollector)
32
    {
33 232
        $this->setMarkerCollector($markerCollector);
34 232
    }
35
36
    /**
37
     * @return MarkerCollector
38
     */
39 4
    public function getMarkerCollector()
40
    {
41 4
        return $this->markerCollector;
42
    }
43
44
    /**
45
     * @param MarkerCollector $markerCollector
46
     */
47 232
    public function setMarkerCollector(MarkerCollector $markerCollector)
48
    {
49 232
        $this->markerCollector = $markerCollector;
50 232
    }
51
52
    /**
53
     * @param Map           $map
54
     * @param MarkerShape[] $markerShapes
55
     *
56
     * @return MarkerShape[]
57
     */
58 224
    public function collect(Map $map, array $markerShapes = [])
59
    {
60 224
        foreach ($this->markerCollector->collect($map) as $marker) {
61 52
            if ($marker->hasShape()) {
62 30
                $markerShapes = $this->collectValue($marker->getShape(), $markerShapes);
0 ignored issues
show
Bug introduced by
It seems like $marker->getShape() 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...
63 4
            }
64 112
        }
65
66 224
        return $markerShapes;
67
    }
68
}
69