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 ( fe542d...f0ddba )
by Eric
13:45
created

KmlLayerSubscriber   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 86
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 86.21%

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 5
dl 86
loc 86
ccs 25
cts 29
cp 0.8621
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 10 10 1
A getKmlLayerCollector() 4 4 1
A setKmlLayerCollector() 4 4 1
A getKmlLayerRenderer() 4 4 1
A setKmlLayerRenderer() 4 4 1
A getSubscribedEvents() 4 4 1
A handleMap() 14 14 2

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\Layer;
13
14
use Ivory\GoogleMap\Helper\Collector\Layer\KmlLayerCollector;
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\Layer\KmlLayerRenderer;
19
use Ivory\GoogleMap\Helper\Subscriber\AbstractSubscriber;
20
21
/**
22
 * @author GeLo <[email protected]>
23
 */
24 View Code Duplication
class KmlLayerSubscriber extends AbstractSubscriber
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 KmlLayerCollector
28
     */
29
    private $kmlLayerCollector;
30
31
    /**
32
     * @var KmlLayerRenderer
33
     */
34
    private $kmlLayerRenderer;
35
36
    /**
37
     * @param Formatter         $formatter
38
     * @param KmlLayerCollector $kmlLayerCollector
39
     * @param KmlLayerRenderer  $kmlLayerRenderer
40
     */
41 224
    public function __construct(
42
        Formatter $formatter,
43
        KmlLayerCollector $kmlLayerCollector,
44
        KmlLayerRenderer $kmlLayerRenderer
45
    ) {
46 224
        parent::__construct($formatter);
47
48 224
        $this->setKmlLayerCollector($kmlLayerCollector);
49 224
        $this->setKmlLayerRenderer($kmlLayerRenderer);
50 224
    }
51
52
    /**
53
     * @return KmlLayerCollector
54
     */
55
    public function getKmlLayerCollector()
56
    {
57
        return $this->kmlLayerCollector;
58
    }
59
60
    /**
61
     * @param KmlLayerCollector $kmlLayerCollector
62
     */
63 224
    public function setKmlLayerCollector(KmlLayerCollector $kmlLayerCollector)
64
    {
65 224
        $this->kmlLayerCollector = $kmlLayerCollector;
66 224
    }
67
68
    /**
69
     * @return KmlLayerRenderer
70
     */
71
    public function getKmlLayerRenderer()
72
    {
73
        return $this->kmlLayerRenderer;
74
    }
75
76
    /**
77
     * @param KmlLayerRenderer $kmlLayerRenderer
78
     */
79 224
    public function setKmlLayerRenderer(KmlLayerRenderer $kmlLayerRenderer)
80
    {
81 224
        $this->kmlLayerRenderer = $kmlLayerRenderer;
82 224
    }
83
84
    /**
85
     * @param MapEvent $event
86
     */
87 220
    public function handleMap(MapEvent $event)
88
    {
89 220
        $formatter = $this->getFormatter();
90 220
        $map = $event->getMap();
91
92 220
        foreach ($this->kmlLayerCollector->collect($map) as $kmlLayer) {
93 8
            $event->addCode($formatter->renderContainerAssignment(
94 4
                $map,
95 8
                $this->kmlLayerRenderer->render($kmlLayer, $map),
96 8
                'layers.kml_layers',
97 4
                $kmlLayer
98 4
            ));
99 110
        }
100 220
    }
101
102
    /**
103
     * {@inheritdoc}
104
     */
105 224
    public static function getSubscribedEvents()
106
    {
107 224
        return [MapEvents::JAVASCRIPT_LAYER_KML_LAYER => 'handleMap'];
108
    }
109
}
110