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 ( 898d2c...c462d0 )
by Eric
24:16 queued 21:28
created

DefaultInfoWindowSubscriber::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 4
cts 4
cp 1
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 3
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\Subscriber\Overlay;
13
14
use Ivory\GoogleMap\Helper\Collector\Overlay\DefaultInfoWindowCollector;
15
use Ivory\GoogleMap\Helper\Collector\Overlay\InfoWindowCollector;
16
use Ivory\GoogleMap\Helper\Event\MapEvent;
17
use Ivory\GoogleMap\Helper\Event\MapEvents;
18
use Ivory\GoogleMap\Helper\Formatter\Formatter;
19
use Ivory\GoogleMap\Helper\Renderer\Overlay\DefaultInfoWindowRenderer;
20
use Ivory\GoogleMap\Map;
21
use Ivory\GoogleMap\Overlay\InfoWindow;
22
23
/**
24
 * @author GeLo <[email protected]>
25
 */
26
class DefaultInfoWindowSubscriber extends AbstractInfoWindowSubscriber
27
{
28
    /**
29
     * @var DefaultInfoWindowRenderer
30
     */
31
    private $infoWindowRenderer;
32
33
    /**
34
     * @param Formatter                  $formatter
35
     * @param DefaultInfoWindowCollector $infoWindowCollector
36
     * @param DefaultInfoWindowRenderer  $infoWindowRenderer
37
     */
38 4
    public function __construct(
39
        Formatter $formatter,
40
        DefaultInfoWindowCollector $infoWindowCollector,
41
        DefaultInfoWindowRenderer $infoWindowRenderer
42
    ) {
43 4
        parent::__construct($formatter, $infoWindowCollector);
44
45 4
        $this->setInfoWindowRenderer($infoWindowRenderer);
46 4
    }
47
48
    /**
49
     * @return DefaultInfoWindowRenderer
50
     */
51
    public function getInfoWindowRenderer()
52
    {
53
        return $this->infoWindowRenderer;
54
    }
55
56
    /**
57
     * @param DefaultInfoWindowRenderer $infoWindowRenderer
58
     */
59 4
    public function setInfoWindowRenderer(DefaultInfoWindowRenderer $infoWindowRenderer)
60
    {
61 4
        $this->infoWindowRenderer = $infoWindowRenderer;
62 4
    }
63
64
    /**
65
     * @param MapEvent $event
66
     */
67 View Code Duplication
    public function handleMap(MapEvent $event)
0 ignored issues
show
Duplication introduced by
This method 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...
68
    {
69
        $map = $event->getMap();
70
        $collector = $this->getInfoWindowCollector();
71
72
        foreach ($collector->collect($map, [], InfoWindowCollector::STRATEGY_MAP) as $infoWindow) {
73
            $event->addCode($this->renderInfoWindow($map, $infoWindow));
74
        }
75
76
        foreach ($collector->collect($map, [], InfoWindowCollector::STRATEGY_MARKER) as $infoWindow) {
77
            $event->addCode($this->renderInfoWindow($map, $infoWindow, false));
78
        }
79
    }
80
81
    /**
82
     * {@inheritdoc}
83
     */
84 4
    public static function getSubscribedEvents()
85
    {
86 4
        return [MapEvents::JAVASCRIPT_OVERLAY_INFO_WINDOW => 'handleMap'];
87
    }
88
89
    /**
90
     * @param Map        $map
91
     * @param InfoWindow $infoWindow
92
     * @param bool       $position
93
     *
94
     * @return string
95
     */
96
    private function renderInfoWindow(Map $map, InfoWindow $infoWindow, $position = true)
97
    {
98
        return $this->getFormatter()->renderContainerAssignment(
99
            $map,
100
            $this->infoWindowRenderer->render($infoWindow, $position),
101
            'overlays.info_windows',
102
            $infoWindow
103
        );
104
    }
105
}
106