ZurbMenuPresenter   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 69
Duplicated Lines 26.09 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 8
lcom 0
cbo 3
dl 18
loc 69
ccs 0
cts 39
cp 0
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getOpenTagWrapper() 0 5 1
A getCloseTagWrapper() 0 4 1
A getMenuWithoutDropdownWrapper() 0 4 1
A getActiveState() 0 4 2
A getDividerWrapper() 0 4 1
A getMenuWithDropDownWrapper() 9 9 1
A getMultiLevelDropdownWrapper() 9 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 Nwidart\Menus\Presenters\Foundation;
4
5
use Nwidart\Menus\Presenters\Presenter;
6
7
class ZurbMenuPresenter extends Presenter
8
{
9
    /**
10
     * {@inheritdoc }
11
     */
12
    public function getOpenTagWrapper()
13
    {
14
        return  PHP_EOL . '<nav class="custom-main">
15
        <ul class="dropdown menu" data-dropdown-menu>' . PHP_EOL;
16
    }
17
18
    /**
19
     * {@inheritdoc }
20
     */
21
    public function getCloseTagWrapper()
22
    {
23
        return  PHP_EOL . '</ul></nav>' . PHP_EOL;
24
    }
25
26
    /**
27
     * {@inheritdoc }
28
     */
29
    public function getMenuWithoutDropdownWrapper($item)
30
    {
31
        return '<li' . $this->getActiveState($item) . '><a href="' . $item->getUrl() . '">' . $item->title . '</a></li>';
32
    }
33
34
    /**
35
     * {@inheritdoc }
36
     */
37
    public function getActiveState($item)
38
    {
39
        return \Request::is($item->getRequest()) ? ' class="is-active"' : null;
40
    }
41
42
    /**
43
     * {@inheritdoc }
44
     */
45
    public function getDividerWrapper()
46
    {
47
        return '<li class="divider"></li>';
48
    }
49
50
    /**
51
     * {@inheritdoc }
52
     */
53 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...
54
    {
55
        return '<li class="dropdown dropdown-primary">
56
                    <a class="dropdown-toggle" href="#">' . $item->title . '</a>
57
                    <ul class="menu">
58
                      ' . $this->getChildMenuItems($item) . '
59
                    </ul>
60
                </li>' . PHP_EOL;
61
    }
62
63
    /**
64
     * {@inheritdoc }
65
     */
66 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...
67
    {
68
        return '<li>
69
                  <a href="#">' . $item->title . '</a>
70
                  <ul class="menu">
71
                    ' . $this->getChildMenuItems($item) . '
72
                  </ul>
73
                </li>' . PHP_EOL;
74
    }
75
}
76