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
Pull Request — master (#217)
by Eric
65:19 queued 62:20
created

MarkerRenderer::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 2
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\Renderer\Image\Overlay;
13
14
use Ivory\GoogleMap\Overlay\Marker;
15
16
/**
17
 * @author GeLo <[email protected]>
18
 */
19
class MarkerRenderer
20
{
21
    /**
22
     * @var MarkerStyleRenderer
23
     */
24
    private $markerStyleRenderer;
25
26
    /**
27
     * @var MarkerLocationRenderer
28
     */
29
    private $markerLocationRenderer;
30
31
    /**
32
     * @param MarkerStyleRenderer    $markerStyleRenderer
33
     * @param MarkerLocationRenderer $markerLocationRenderer
34
     */
35
    public function __construct(
36
        MarkerStyleRenderer $markerStyleRenderer,
37
        MarkerLocationRenderer $markerLocationRenderer
38
    ) {
39
        $this->markerStyleRenderer = $markerStyleRenderer;
40
        $this->markerLocationRenderer = $markerLocationRenderer;
41
    }
42
43
    /**
44
     * @param Marker[] $markers
45
     *
46
     * @return string
47
     */
48
    public function render(array $markers)
49
    {
50
        $result = [];
51
        $marker = current($markers);
52
        $style = $this->markerStyleRenderer->render($marker);
0 ignored issues
show
Security Bug introduced by
It seems like $marker defined by current($markers) on line 51 can also be of type false; however, Ivory\GoogleMap\Helper\R...StyleRenderer::render() does only seem to accept object<Ivory\GoogleMap\Overlay\Marker>, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
53
54
        if (!empty($style)) {
55
            $result[] = $style;
56
        }
57
58
        foreach ($markers as $marker) {
59
            $result[] = $this->markerLocationRenderer->render($marker);
60
        }
61
62
        return implode('|', $result);
63
    }
64
}
65