Completed
Push — develop ( 5abd4c...dae2aa )
by Abdelrahman
09:07
created

getMenuWithoutDropdownWrapper()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 3
eloc 5
nc 4
nop 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>';
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 123 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
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();
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