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

EncodedPolylineSubscriber   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 42
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A handleMap() 0 6 2
A getSubscribedEvents() 0 4 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\Subscriber\Image;
13
14
use Ivory\GoogleMap\Helper\Collector\Image\EncodedPolylineCollector;
15
use Ivory\GoogleMap\Helper\Event\StaticMapEvent;
16
use Ivory\GoogleMap\Helper\Event\StaticMapEvents;
17
use Ivory\GoogleMap\Helper\Renderer\Image\Overlay\EncodedPolylineRenderer;
18
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
19
20
/**
21
 * @author GeLo <[email protected]>
22
 */
23
class EncodedPolylineSubscriber implements EventSubscriberInterface
24
{
25
    /**
26
     * @var EncodedPolylineCollector
27
     */
28
    private $encodedPolylineCollector;
29
30
    /**
31
     * @var EncodedPolylineRenderer
32
     */
33
    private $encodedPolylineRenderer;
34
35
    /**
36
     * @param EncodedPolylineCollector $encodedPolylineCollector
37
     * @param EncodedPolylineRenderer  $encodedPolylineRenderer
38
     */
39
    public function __construct(
40
        EncodedPolylineCollector $encodedPolylineCollector,
41
        EncodedPolylineRenderer $encodedPolylineRenderer
42
    ) {
43
        $this->encodedPolylineCollector = $encodedPolylineCollector;
44
        $this->encodedPolylineRenderer = $encodedPolylineRenderer;
45
    }
46
47
    /**
48
     * @param StaticMapEvent $event
49
     */
50
    public function handleMap(StaticMapEvent $event)
51
    {
52
        foreach ($this->encodedPolylineCollector->collect($event->getMap()) as $encodedPolylines) {
53
            $event->setParameter('path', $this->encodedPolylineRenderer->render($encodedPolylines));
0 ignored issues
show
Documentation introduced by
$encodedPolylines is of type array<integer,object<Ivo...erlay\EncodedPolyline>>, but the function expects a object<Ivory\GoogleMap\Overlay\EncodedPolyline>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
54
        }
55
    }
56
57
    /**
58
     * {@inheritdoc}
59
     */
60
    public static function getSubscribedEvents()
61
    {
62
        return [StaticMapEvents::ENCODED_POLYLINE => 'handleMap'];
63
    }
64
}
65