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

MarkerSubscriber   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 69
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 8

Test Coverage

Coverage 34.62%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 8
dl 69
loc 69
ccs 9
cts 26
cp 0.3462
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 9 9 1
A getMarkerRenderer() 4 4 1
A setMarkerRenderer() 4 4 1
A getSubscribedEvents() 4 4 1
A handleMap() 19 19 3

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\MarkerCollector;
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\MarkerRenderer;
19
use Ivory\GoogleMap\Overlay\MarkerClusterType;
20
21
/**
22
 * @author GeLo <[email protected]>
23
 */
24 View Code Duplication
class MarkerSubscriber extends AbstractMarkerSubscriber
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...
25
{
26
    /**
27
     * @var MarkerRenderer
28
     */
29
    private $markerRenderer;
30
31
    /**
32
     * @param Formatter       $formatter
33
     * @param MarkerCollector $markerCollector
34
     * @param MarkerRenderer  $markerRenderer
35
     */
36 4
    public function __construct(
37
        Formatter $formatter,
38
        MarkerCollector $markerCollector,
39
        MarkerRenderer $markerRenderer
40
    ) {
41 4
        parent::__construct($formatter, $markerCollector);
42
43 4
        $this->setMarkerRenderer($markerRenderer);
44 4
    }
45
46
    /**
47
     * @return MarkerRenderer
48
     */
49
    public function getMarkerRenderer()
50
    {
51
        return $this->markerRenderer;
52
    }
53
54
    /**
55
     * @param MarkerRenderer $markerRenderer
56
     */
57 4
    public function setMarkerRenderer(MarkerRenderer $markerRenderer)
58
    {
59 4
        $this->markerRenderer = $markerRenderer;
60 4
    }
61
62
    /**
63
     * @param MapEvent $event
64
     */
65
    public function handleMap(MapEvent $event)
66
    {
67
        $formatter = $this->getFormatter();
68
        $map = $event->getMap();
69
        $markerMap = null;
70
71
        if ($map->getOverlayManager()->getMarkerCluster()->getType() === MarkerClusterType::DEFAULT_) {
72
            $markerMap = $map;
73
        }
74
75
        foreach ($this->getMarkerCollector()->collect($map) as $marker) {
76
            $event->addCode($formatter->renderContainerAssignment(
77
                $map,
78
                $this->markerRenderer->render($marker, $markerMap),
79
                'overlays.markers',
80
                $marker
81
            ));
82
        }
83
    }
84
85
    /**
86
     * {@inheritdoc}
87
     */
88 4
    public static function getSubscribedEvents()
89
    {
90 4
        return [MapEvents::JAVASCRIPT_OVERLAY_MARKER => 'handleMap'];
91
    }
92
}
93