Completed
Push — master ( 3182b0...115a8b )
by Arkadiusz
11s
created

ContentMenuBuilder   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 61
Duplicated Lines 49.18 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 2
dl 30
loc 61
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A configureRouteMenu() 10 10 1
A configureStaticContentMenu() 10 10 1
A configureStringBlockMenu() 10 10 1
A getContentMenu() 0 11 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 Lakion\SyliusCmsBundle\Menu;
4
5
use Knp\Menu\ItemInterface;
6
use Sylius\Bundle\UiBundle\Menu\Event\MenuBuilderEvent;
7
8
final class ContentMenuBuilder
9
{
10
    /**
11
     * @param MenuBuilderEvent $event
12
     */
13 View Code Duplication
    public function configureRouteMenu(MenuBuilderEvent $event)
0 ignored issues
show
Duplication introduced by
This method 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...
14
    {
15
        $contentMenu = $this->getContentMenu($event);
16
17
        $contentMenu
18
            ->addChild('routes', ['route' => 'lakion_sylius_cms_admin_route_index'])
19
            ->setLabel('lakion_sylius_cms.menu.admin.routes')
20
            ->setLabelAttribute('icon', 'sitemap')
21
        ;
22
    }
23
24
    /**
25
     * @param MenuBuilderEvent $event
26
     */
27 View Code Duplication
    public function configureStaticContentMenu(MenuBuilderEvent $event)
0 ignored issues
show
Duplication introduced by
This method 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...
28
    {
29
        $contentMenu = $this->getContentMenu($event);
30
31
        $contentMenu
32
            ->addChild('static_contents', ['route' => 'lakion_sylius_cms_admin_static_content_index'])
33
            ->setLabel('lakion_sylius_cms.menu.admin.static_contents')
34
            ->setLabelAttribute('icon', 'file')
35
        ;
36
    }
37
38
    /**
39
     * @param MenuBuilderEvent $event
40
     */
41 View Code Duplication
    public function configureStringBlockMenu(MenuBuilderEvent $event)
0 ignored issues
show
Duplication introduced by
This method 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...
42
    {
43
        $contentMenu = $this->getContentMenu($event);
44
45
        $contentMenu
46
            ->addChild('string_blocks', ['route' => 'lakion_sylius_cms_admin_string_block_index'])
47
            ->setLabel('lakion_sylius_cms.menu.admin.string_blocks')
48
            ->setLabelAttribute('icon', 'font')
49
        ;
50
    }
51
52
    /**
53
     * @param MenuBuilderEvent $event
54
     *
55
     * @return ItemInterface
56
     */
57
    private function getContentMenu(MenuBuilderEvent $event)
58
    {
59
        $adminMenu = $event->getMenu();
60
61
        $contentMenu = $adminMenu
62
            ->addChild('content')
63
            ->setLabel('lakion_sylius_cms.menu.admin.header')
64
        ;
65
66
        return $contentMenu;
67
    }
68
}
69