Code Duplication    Length = 113-117 lines in 2 locations

src/Presenters/Admin/AdminltePresenter.php 1 location

@@ 7-123 (lines=117) @@
4
5
use Nwidart\Menus\Presenters\Presenter;
6
7
class AdminltePresenter extends Presenter
8
{
9
    /**
10
     * {@inheritdoc }.
11
     */
12
    public function getOpenTagWrapper()
13
    {
14
        return PHP_EOL . '<ul class="sidebar-menu tree" data-widget="tree">' . PHP_EOL;
15
    }
16
17
    /**
18
     * {@inheritdoc }.
19
     */
20
    public function getCloseTagWrapper()
21
    {
22
        return PHP_EOL . '</ul>' . PHP_EOL;
23
    }
24
25
    /**
26
     * {@inheritdoc }.
27
     */
28
    public function getMenuWithoutDropdownWrapper($item)
29
    {
30
        if($item->auth && auth()->guest()) {
31
            return null;
32
        }
33
34
        return '<li' . $this->getActiveState($item) . '><a href="' . $item->getUrl() . '" ' . $item->getAttributes() . '>' . $item->getIcon() . ' <span>' . $item->title . '</span></a></li>' . PHP_EOL;
35
    }
36
37
    /**
38
     * {@inheritdoc }.
39
     */
40
    public function getActiveState($item, $state = ' class="active"')
41
    {
42
        return $item->isActive() ? $state : null;
43
    }
44
45
    /**
46
     * Get active state on child items.
47
     *
48
     * @param $item
49
     * @param string $state
50
     *
51
     * @return null|string
52
     */
53
    public function getActiveStateOnChild($item, $state = 'active')
54
    {
55
        return $item->hasActiveOnChild() ? $state : null;
56
    }
57
58
    /**
59
     * {@inheritdoc }.
60
     */
61
    public function getDividerWrapper()
62
    {
63
        return '<li class="divider"></li>';
64
    }
65
66
    /**
67
     * {@inheritdoc }.
68
     */
69
    public function getHeaderWrapper($item)
70
    {
71
        return '<li class="header">' . $item->title . '</li>';
72
    }
73
74
    /**
75
     * {@inheritdoc }.
76
     */
77
    public function getMenuWithDropDownWrapper($item)
78
    {
79
        if($item->auth && auth()->guest()) {
80
            return null;
81
        }
82
83
        return '<li class="treeview' . $this->getActiveStateOnChild($item, ' active') . '">
84
		          <a href="#">
85
					' . $item->getIcon() . ' <span>' . $item->title . '</span>
86
                    <span class="pull-right-container">
87
                      <i class="fa fa-angle-left pull-right"></i>
88
                    </span>
89
			      </a>
90
			      <ul class="treeview-menu">
91
			      	' . $this->getChildMenuItems($item) . '
92
			      </ul>
93
		      	</li>'
94
        . PHP_EOL;
95
    }
96
97
    /**
98
     * Get multilevel menu wrapper.
99
     *
100
     * @param \Nwidart\Menus\MenuItem $item
101
     *
102
     * @return string`
103
     */
104
    public function getMultiLevelDropdownWrapper($item)
105
    {
106
        if($item->auth && auth()->guest()) {
107
            return null;
108
        }
109
110
        return '<li class="treeview' . $this->getActiveStateOnChild($item, ' active') . '">
111
		          <a href="#">
112
					' . $item->getIcon() . ' <span>' . $item->title . '</span>
113
			      	<span class="pull-right-container">
114
                      <i class="fa fa-angle-left pull-right"></i>
115
                    </span>
116
			      </a>
117
			      <ul class="treeview-menu">
118
			      	' . $this->getChildMenuItems($item) . '
119
			      </ul>
120
		      	</li>'
121
        . PHP_EOL;
122
    }
123
}
124

src/Presenters/Bootstrap/NavbarPresenter.php 1 location

@@ 7-119 (lines=113) @@
4
5
use Nwidart\Menus\Presenters\Presenter;
6
7
class NavbarPresenter extends Presenter
8
{
9
    /**
10
     * {@inheritdoc }.
11
     */
12
    public function getOpenTagWrapper()
13
    {
14
        return PHP_EOL . '<ul class="nav navbar-nav">' . PHP_EOL;
15
    }
16
17
    /**
18
     * {@inheritdoc }.
19
     */
20
    public function getCloseTagWrapper()
21
    {
22
        return PHP_EOL . '</ul>' . PHP_EOL;
23
    }
24
25
    /**
26
     * {@inheritdoc }.
27
     */
28
    public function getMenuWithoutDropdownWrapper($item)
29
    {
30
        if($item->auth && auth()->guest()) {
31
            return null;
32
        }
33
34
        return '<li' . $this->getActiveState($item) . '><a href="' . $item->getUrl() . '" ' . $item->getAttributes() . '>' . $item->getIcon() . ' ' . $item->title . '</a></li>' . PHP_EOL;
35
    }
36
37
    /**
38
     * {@inheritdoc }.
39
     */
40
    public function getActiveState($item, $state = ' class="active"')
41
    {
42
        return $item->isActive() ? $state : null;
43
    }
44
45
    /**
46
     * Get active state on child items.
47
     *
48
     * @param $item
49
     * @param string $state
50
     *
51
     * @return null|string
52
     */
53
    public function getActiveStateOnChild($item, $state = 'active')
54
    {
55
        return $item->hasActiveOnChild() ? $state : null;
56
    }
57
58
    /**
59
     * {@inheritdoc }.
60
     */
61
    public function getDividerWrapper()
62
    {
63
        return '<li class="divider"></li>';
64
    }
65
66
    /**
67
     * {@inheritdoc }.
68
     */
69
    public function getHeaderWrapper($item)
70
    {
71
        return '<li class="dropdown-header">' . $item->title . '</li>';
72
    }
73
74
    /**
75
     * {@inheritdoc }.
76
     */
77
    public function getMenuWithDropDownWrapper($item)
78
    {
79
        if($item->auth && auth()->guest()) {
80
            return null;
81
        }
82
83
        return '<li class="dropdown' . $this->getActiveStateOnChild($item, ' active') . '">
84
		          <a href="#" class="dropdown-toggle" data-toggle="dropdown">
85
					' . $item->getIcon() . ' ' . $item->title . '
86
			      	<b class="caret"></b>
87
			      </a>
88
			      <ul class="dropdown-menu">
89
			      	' . $this->getChildMenuItems($item) . '
90
			      </ul>
91
		      	</li>'
92
        . PHP_EOL;
93
    }
94
95
    /**
96
     * Get multilevel menu wrapper.
97
     *
98
     * @param \Nwidart\Menus\MenuItem $item
99
     *
100
     * @return string`
101
     */
102
    public function getMultiLevelDropdownWrapper($item)
103
    {
104
        if($item->auth && auth()->guest()) {
105
            return null;
106
        }
107
108
        return '<li class="dropdown' . $this->getActiveStateOnChild($item, ' active') . '">
109
		          <a href="#" class="dropdown-toggle" data-toggle="dropdown">
110
					' . $item->getIcon() . ' ' . $item->title . '
111
			      	<b class="caret pull-right caret-right"></b>
112
			      </a>
113
			      <ul class="dropdown-menu">
114
			      	' . $this->getChildMenuItems($item) . '
115
			      </ul>
116
		      	</li>'
117
        . PHP_EOL;
118
    }
119
}
120