Completed
Push — master ( 2dffbe...813169 )
by Jose Luis
14:24
created

SidebarMenuPresenter   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 53
Duplicated Lines 50.94 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 3
Bugs 1 Features 0
Metric Value
wmc 4
c 3
b 1
f 0
lcom 1
cbo 2
dl 27
loc 53
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getOpenTagWrapper() 0 4 1
A getMenuWithoutDropdownWrapper() 0 4 1
A getMenuWithDropDownWrapper() 14 14 1
A getMultiLevelDropdownWrapper() 13 13 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 Hechoenlaravel\JarvisFoundation\Menu\Presenters;
4
5
use Pingpong\Menus\Presenters\Bootstrap\NavbarPresenter;
6
7
class SidebarMenuPresenter extends NavbarPresenter
8
{
9
    /**
10
     * {@inheritdoc}
11
     */
12
    public function getOpenTagWrapper()
13
    {
14
        return PHP_EOL . '<ul class="sidebar-menu">' . PHP_EOL;
15
    }
16
17
    /**
18
     * {@inheritdoc}
19
     */
20 View Code Duplication
    public function getMenuWithDropDownWrapper($item)
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...
21
    {
22
        return '
23
      		<li class="treeview' . $this->getActiveStateOnChild($item, ' active') . '">
24
                <a href="#">
25
                    ' . $item->getIcon() . '
26
                    <span>' . $item->title . '</span>
27
                    <i class="fa fa-angle-left pull-right"></i>
28
                </a>
29
                <ul class="treeview-menu">
30
                    ' . $this->getChildMenuItems($item) . '
31
                </ul>
32
            </li>';
33
    }
34
35
    /**
36
     * {@inheritdoc }.
37
     */
38
    public function getMenuWithoutDropdownWrapper($item)
39
    {
40
        return '<li'.$this->getActiveState($item).'><a href="'.$item->getUrl().'" '.$item->getAttributes().'>'.$item->getIcon().' <span>'.$item->title.'</span></a></li>'.PHP_EOL;
41
    }
42
43
    /**
44
     * {@inheritdoc }.
45
     */
46 View Code Duplication
    public function getMultiLevelDropdownWrapper($item)
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...
47
    {
48
        return '<li class="'.$this->getActiveStateOnChild($item, ' active').'">
49
		          <a href="#">
50
					'.$item->getIcon().' '.$item->title.'
51
			      	<i class="fa fa-angle-left pull-right"></i>
52
			      </a>
53
			      <ul class="treeview-menu">
54
			      	'.$this->getChildMenuItems($item).'
55
			      </ul>
56
		      	</li>'
57
        .PHP_EOL;
58
    }
59
}
60