Completed
Pull Request — master (#34)
by
unknown
03:42
created

Presenter   A

Complexity

Total Complexity 17

Size/Duplication

Total Lines 130
Duplicated Lines 10.77 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 17
lcom 1
cbo 1
dl 14
loc 130
ccs 0
cts 35
cp 0
rs 10
c 0
b 0
f 0

10 Methods

Rating   Name   Duplication   Size   Complexity  
A getOpenTagWrapper() 0 3 1
A getCloseTagWrapper() 0 4 1
A getOpenTagA() 7 7 2
A getCloseTagA() 7 7 2
A getMenuWithoutDropdownWrapper() 0 3 1
A getDividerWrapper() 0 3 1
A getHeaderWrapper() 0 3 1
A getMenuWithDropDownWrapper() 0 3 1
A getMultiLevelDropdownWrapper() 0 3 1
B getChildMenuItems() 0 21 6

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;
4
5
use Nwidart\Menus\MenuItem;
6
7
abstract class Presenter implements PresenterInterface
8
{
9
    /**
10
     * Get open tag wrapper.
11
     *
12
     * @return string
13
     */
14
    public function getOpenTagWrapper()
15
    {
16
    }
17
18
    /**
19
     * Get close tag wrapper.
20
     *
21
     * @return string
22
     */
23
    public function getCloseTagWrapper()
24
    {
25
26
    }
27
28
    /**
29
     * Get open tag A.
30
     *
31
     * @return string
32
     */
33 View Code Duplication
    public function getOpenTagA($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...
34
    {
35
        if($item->attributes['vue']){
36
            return PHP_EOL . '<router-link to="' . PHP_EOL;
37
        }
38
        return PHP_EOL . '<a href=">' . PHP_EOL;
39
    }
40
41
    /**
42
     * Get close tag A.
43
     *
44
     * @return string
45
     */
46 View Code Duplication
    public function getCloseTagA($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
        if($item->attributes['vue']){
49
            return PHP_EOL . '</router-link>' . PHP_EOL;
50
        }
51
        return PHP_EOL . '</a>' . PHP_EOL;
52
    }
53
54
55
    /**
56
     * Get menu tag without dropdown wrapper.
57
     *
58
     * @param \Nwidart\Menus\MenuItem $item
59
     *
60
     * @return string
61
     */
62
    public function getMenuWithoutDropdownWrapper($item)
63
    {
64
    }
65
66
    /**
67
     * Get divider tag wrapper.
68
     *
69
     * @return string
70
     */
71
    public function getDividerWrapper()
72
    {
73
    }
74
75
    /**
76
     * Get header dropdown tag wrapper.
77
     *
78
     * @param \Nwidart\Menus\MenuItem $item
79
     *
80
     * @return string
81
     */
82
    public function getHeaderWrapper($item)
83
    {
84
    }
85
86
    /**
87
     * Get menu tag with dropdown wrapper.
88
     *
89
     * @param \Nwidart\Menus\MenuItem $item
90
     *
91
     * @return string
92
     */
93
    public function getMenuWithDropDownWrapper($item)
94
    {
95
    }
96
97
    /**
98
     * Get multi level dropdown menu wrapper.
99
     *
100
     * @param \Nwidart\Menus\MenuItem $item
101
     *
102
     * @return string
103
     */
104
    public function getMultiLevelDropdownWrapper($item)
105
    {
106
    }
107
108
    /**
109
     * Get child menu items.
110
     *
111
     * @param \Nwidart\Menus\MenuItem $item
112
     *
113
     * @return string
114
     */
115
    public function getChildMenuItems(MenuItem $item)
116
    {
117
        $results = '';
118
        foreach ($item->getChilds() as $child) {
119
            if ($child->hidden()) {
120
                continue;
121
            }
122
123
            if ($child->hasSubMenu()) {
124
                $results .= $this->getMultiLevelDropdownWrapper($child);
125
            } elseif ($child->isHeader()) {
126
                $results .= $this->getHeaderWrapper($child);
127
            } elseif ($child->isDivider()) {
128
                $results .= $this->getDividerWrapper();
129
            } else {
130
                $results .= $this->getMenuWithoutDropdownWrapper($child);
131
            }
132
        }
133
134
        return $results;
135
    }
136
}
137