Completed
Pull Request — master (#151)
by De Cramer
03:02
created

MenuItems   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 48
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 1
c 0
b 0
f 0
lcom 0
cbo 0
dl 48
loc 48
ccs 0
cts 31
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B registerMenuItems() 37 37 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 eXpansion\Bundle\LocalRecords\Plugins;
4
5
use eXpansion\Bundle\Menu\DataProviders\Listener\ListenerMenuItemProviderInterface;
6
use eXpansion\Bundle\Menu\Model\Menu\ChatCommandItem;
7
use eXpansion\Bundle\Menu\Model\Menu\ParentItem;
8
9
10
/**
11
 * Class MenuItems
12
 *
13
 * @package eXpansion\Bundle\LocalRecords\Plugins;
14
 * @author  oliver de Cramer <[email protected]>
15
 */
16 View Code Duplication
class MenuItems implements ListenerMenuItemProviderInterface
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...
17
{
18
19
    /**
20
     * Register items tot he parent item.
21
     *
22
     * @param ParentItem $root
23
     *
24
     * @return mixed
25
     */
26
    public function registerMenuItems(ParentItem $root)
27
    {
28
        $root->addChild(
29
            ParentItem::class,
30
            'records',
31
            'expansion_local_records.menu.label',
32
            null // Permission are handled by sub elements.
33
        );
34
        $root->addChild(
35
            ChatCommandItem::class,
36
            'records/list',
37
            'expansion_local_records.menu.race_recs',
38
            null,
39
            ['cmd' => '/recs']
40
        );
41
        $root->addChild(
42
            ChatCommandItem::class,
43
            'records/laps',
44
            'expansion_local_records.menu.laps_recs',
45
            null,
46
            ['cmd' => '/dummy']
47
        );
48
        $root->addChild(
49
            ChatCommandItem::class,
50
            'records/prev_list',
51
            'expansion_local_records.menu.prev.race_recs',
52
            null,
53
            ['cmd' => '/dummy']
54
        );
55
        $root->addChild(
56
            ChatCommandItem::class,
57
            'records/prev_laps',
58
            'expansion_local_records.menu.prev.laps_recs',
59
            null,
60
            ['cmd' => '/dummy']
61
        );
62
    }
63
}