AccountSidebarMenuPresenter   A
last analyzed

Complexity

Total Complexity 14

Size/Duplication

Total Lines 91
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 14
lcom 1
cbo 2
dl 0
loc 91
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getOpenTagWrapper() 0 4 1
A getCloseTagWrapper() 0 4 1
A getDividerWrapper() 0 4 1
A getHeaderWrapper() 0 4 2
A getMenuWithoutDropdownWrapper() 0 9 3
A getMenuWithDropDownWrapper() 0 20 5
A getMultiLevelDropdownWrapper() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cortex\Auth\Presenters;
6
7
use Rinvex\Menus\Models\MenuItem;
8
use Rinvex\Menus\Presenters\BasePresenter;
9
10
class AccountSidebarMenuPresenter extends BasePresenter
11
{
12
    /**
13
     * Get open tag wrapper.
14
     *
15
     * @return string
16
     */
17
    public function getOpenTagWrapper(): string
18
    {
19
        return '<ul class="nav">';
20
    }
21
22
    /**
23
     * Get close tag wrapper.
24
     *
25
     * @return string
26
     */
27
    public function getCloseTagWrapper(): string
28
    {
29
        return '</ul>';
30
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35
    public function getDividerWrapper(): string
36
    {
37
        return '<li class="divider"></li>';
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43
    public function getHeaderWrapper(MenuItem $item): string
44
    {
45
        return '<li class="dropdown-header">'.($item->icon ? '<i class="'.$item->icon.'"></i> ' : '').$item->title.'</li>';
46
    }
47
48
    /**
49
     * Get menu tag without dropdown wrapper.
50
     *
51
     * @param \Rinvex\Menus\Models\MenuItem $item
52
     *
53
     * @return string
54
     */
55
    public function getMenuWithoutDropdownWrapper(MenuItem $item): string
56
    {
57
        return '<li class="'.($item->isActive() ? 'active' : '').'">
58
                    <a href="'.$item->getUrl().'" '.$item->getAttributes().'>
59
                        '.($item->icon ? '<i class="'.$item->icon.'"></i>' : '').'
60
                        '.$item->title.'
61
                    </a>
62
                </li>';
63
    }
64
65
    /**
66
     * {@inheritdoc}
67
     */
68
    public function getMenuWithDropDownWrapper(MenuItem $item, bool $specialSidebar = false): string
69
    {
70
        $id = str_random();
0 ignored issues
show
Deprecated Code introduced by
The function str_random() has been deprecated with message: Str::random() should be used directly instead. Will be removed in Laravel 6.0.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
71
72
        return $specialSidebar
73
            ? $this->getHeaderWrapper($item).$this->getChildMenuItems($item)
74
            : '<li class="panel panel-default'.($item->hasActiveOnChild() ? ' active' : '').'" id="dropdown">
75
                    <a data-toggle="collapse" href="#'.$id.'">
76
                        '.($item->icon ? '<i class="'.$item->icon.'"></i>' : '').'
77
                        '.$item->title.' <span class="caret"></span>
78
                    </a>
79
                    <div id="'.$id.'" class="panel-collapse collapse'.($item->hasActiveOnChild() ? ' in' : '').'">
80
                        <div class="panel-body">
81
                            <ul class="nav navbar-nav">
82
                                '.$this->getChildMenuItems($item).'
83
                            </ul>
84
                        </div>
85
                    </div>
86
                </li>';
87
    }
88
89
    /**
90
     * Get multilevel menu wrapper.
91
     *
92
     * @param \Rinvex\Menus\Models\MenuItem $item
93
     *
94
     * @return string
95
     */
96
    public function getMultiLevelDropdownWrapper(MenuItem $item): string
97
    {
98
        return $this->getMenuWithDropDownWrapper($item);
99
    }
100
}
101