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

InfoWindowCloseSubscriber   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 68
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 6

Test Coverage

Coverage 92.31%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 6
dl 68
loc 68
ccs 24
cts 26
cp 0.9231
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 9 9 1
A getInfoWindowCloseRenderer() 4 4 1
A setInfoWindowCloseRenderer() 4 4 1
A handleMap() 18 18 3
A getSubscribedEvents() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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\InfoWindowCollector;
15
use Ivory\GoogleMap\Helper\Event\MapEvent;
16
use Ivory\GoogleMap\Helper\Event\MapEvents;
17
use Ivory\GoogleMap\Helper\Formatter\Formatter;
18
use Ivory\GoogleMap\Helper\Renderer\Overlay\InfoWindowCloseRenderer;
19
20
/**
21
 * @author GeLo <[email protected]>
22
 */
23 View Code Duplication
class InfoWindowCloseSubscriber extends AbstractInfoWindowSubscriber
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...
24
{
25
    /**
26
     * @var InfoWindowCloseRenderer
27
     */
28
    private $infoWindowCloseRenderer;
29
30
    /**
31
     * @param Formatter               $formatter
32
     * @param InfoWindowCollector     $infoWindowCollector
33
     * @param InfoWindowCloseRenderer $infoWindowCloseRenderer
34
     */
35 224
    public function __construct(
36
        Formatter $formatter,
37
        InfoWindowCollector $infoWindowCollector,
38
        InfoWindowCloseRenderer $infoWindowCloseRenderer
39
    ) {
40 224
        parent::__construct($formatter, $infoWindowCollector);
41
42 224
        $this->setInfoWindowCloseRenderer($infoWindowCloseRenderer);
43 224
    }
44
45
    /**
46
     * @return InfoWindowCloseRenderer
47
     */
48
    public function getInfoWindowCloseRenderer()
49
    {
50
        return $this->infoWindowCloseRenderer;
51
    }
52
53
    /**
54
     * @param InfoWindowCloseRenderer $infoWindowCloseRenderer
55
     */
56 224
    public function setInfoWindowCloseRenderer(InfoWindowCloseRenderer $infoWindowCloseRenderer)
57
    {
58 224
        $this->infoWindowCloseRenderer = $infoWindowCloseRenderer;
59 224
    }
60
61
    /**
62
     * @param MapEvent $event
63
     */
64 220
    public function handleMap(MapEvent $event)
65
    {
66 220
        $formatter = $this->getFormatter();
67 220
        $map = $event->getMap();
68 220
        $codes = [];
69
70 220
        foreach ($this->getInfoWindowCollector()->collect($map) as $infoWindow) {
71 48
            if ($infoWindow->isAutoClose()) {
72 48
                $codes[] = $formatter->renderCode($this->infoWindowCloseRenderer->render($infoWindow), true, false);
73 24
            }
74 110
        }
75
76 220
        $event->addCode($formatter->renderContainerAssignment(
77 110
            $map,
78 220
            $formatter->renderClosure($formatter->renderLines($codes)),
79 110
            'functions.info_windows_close'
80 110
        ));
81 220
    }
82
83
    /**
84
     * {@inheritdoc}
85
     */
86 224
    public static function getSubscribedEvents()
87
    {
88 224
        return [MapEvents::JAVASCRIPT_INIT_FUNCTION => 'handleMap'];
89
    }
90
}
91