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 — custom-control ( 2eba71 )
by Eric
02:57
created

CustomControlSubscriber   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 81
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 8
c 1
b 0
f 1
lcom 1
cbo 5
dl 81
loc 81
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 10 10 1
A getCustomControlCollector() 4 4 1
A setCustomControlCollector() 4 4 1
A getCustomControlRenderer() 4 4 1
A setCustomControlRenderer() 4 4 1
A handleMap() 9 9 2
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\Control;
13
14
use Ivory\GoogleMap\Helper\Collector\Control\CustomControlCollector;
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\Control\CustomControlRenderer;
19
use Ivory\GoogleMap\Helper\Subscriber\AbstractSubscriber;
20
21
/**
22
 * @author GeLo <[email protected]>
23
 */
24 View Code Duplication
class CustomControlSubscriber 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 CustomControlCollector
28
     */
29
    private $customControlCollector;
30
31
    /**
32
     * @var CustomControlRenderer
33
     */
34
    private $customControlRenderer;
35
36
    /**
37
     * @param Formatter              $formatter
38
     * @param CustomControlCollector $customControlCollector
39
     * @param CustomControlRenderer  $customControlRenderer
40
     */
41
    public function __construct(
42
        Formatter $formatter,
43
        CustomControlCollector $customControlCollector,
44
        CustomControlRenderer $customControlRenderer
45
    ) {
46
        parent::__construct($formatter);
47
48
        $this->setCustomControlCollector($customControlCollector);
49
        $this->setCustomControlRenderer($customControlRenderer);
50
    }
51
52
    /**
53
     * @return CustomControlCollector
54
     */
55
    public function getCustomControlCollector()
56
    {
57
        return $this->customControlCollector;
58
    }
59
60
    /**
61
     * @param CustomControlCollector $customControlCollector
62
     */
63
    public function setCustomControlCollector(CustomControlCollector $customControlCollector)
64
    {
65
        $this->customControlCollector = $customControlCollector;
66
    }
67
68
    /**
69
     * @return CustomControlRenderer
70
     */
71
    public function getCustomControlRenderer()
72
    {
73
        return $this->customControlRenderer;
74
    }
75
76
    /**
77
     * @param CustomControlRenderer $customControlRenderer
78
     */
79
    public function setCustomControlRenderer(CustomControlRenderer $customControlRenderer)
80
    {
81
        $this->customControlRenderer = $customControlRenderer;
82
    }
83
84
    /**
85
     * @param MapEvent $event
86
     */
87
    public function handleMap(MapEvent $event)
88
    {
89
        $formatter = $this->getFormatter();
90
        $map = $event->getMap();
91
92
        foreach ($this->customControlCollector->collect($map) as $customControl) {
93
            $event->addCode($formatter->renderCode($this->customControlRenderer->render($customControl, $map)));
94
        }
95
    }
96
97
    /**
98
     * {@inheritdoc}
99
     */
100
    public static function getSubscribedEvents()
101
    {
102
        return [MapEvents::JAVASCRIPT_CONTROL_CUSTOM => 'handleMap'];
103
    }
104
}
105