Completed
Push — development ( 0937b7...1a7c5e )
by Thomas
21s
created

MenuSubscriber   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 88.89 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 24
loc 27
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSubscribedEvents() 6 6 1
A onConfigureMenu() 7 9 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
namespace Oc\Changelog\Subscriber;
4
5
use Oc\Menu\Event\MenuEvent;
6
use Oc\Menu\MenuEnum;
7
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
8
9
/**
10
 * Class MenuSubscriber
11
 *
12
 * @package Oc\Changelog\Subscriber
13
 */
14 View Code Duplication
class MenuSubscriber implements EventSubscriberInterface
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...
15
{
16
    /**
17
     * Returns an array of event names this subscriber wants to listen to.
18
     *
19
     * @return array The event names to listen to
20
     */
21
    public static function getSubscribedEvents()
22
    {
23
        return [
24
            MenuEnum::MENU_MAIN => 'onConfigureMenu'
25
        ];
26
    }
27
28
    /**
29
     * @param MenuEvent $event
30
     */
31
    public function onConfigureMenu(MenuEvent $event)
32
    {
33
        $event->getCurrentItem()->addChild(
34
            'Changelog',
35
            [
36
                'route' => 'changelog.index'
37
            ]
38
        );
39
    }
40
}
41