1 | <?php |
||||
2 | |||||
3 | namespace KyleMassacre\Menus\Presenters\Bootstrap; |
||||
4 | |||||
5 | use Illuminate\Support\Str; |
||||
6 | use KyleMassacre\Menus\Contracts\MenuItemContract; |
||||
7 | use KyleMassacre\Menus\Presenters\Presenter; |
||||
8 | |||||
9 | class SidebarMenuPresenter extends Presenter |
||||
10 | { |
||||
11 | /** |
||||
12 | * Get open tag wrapper. |
||||
13 | * |
||||
14 | * @return string |
||||
15 | */ |
||||
16 | public function getOpenTagWrapper(): ?string |
||||
17 | { |
||||
18 | return '<ul class="nav navbar-nav">'; |
||||
19 | } |
||||
20 | |||||
21 | /** |
||||
22 | * Get close tag wrapper. |
||||
23 | * |
||||
24 | * @return string |
||||
25 | */ |
||||
26 | public function getCloseTagWrapper(): ?string |
||||
27 | { |
||||
28 | return '</ul>'; |
||||
29 | } |
||||
30 | |||||
31 | /** |
||||
32 | * Get menu tag without dropdown wrapper. |
||||
33 | * |
||||
34 | * @param MenuItemContract $item |
||||
35 | * |
||||
36 | * @return string |
||||
37 | */ |
||||
38 | public function getMenuWithoutDropdownWrapper(MenuItemContract $item): ?string |
||||
39 | { |
||||
40 | return '<li' . $this->getActiveState($item) . '> |
||||
41 | <a href="' . $item->getUrl() . '" ' . $item->getAttributes() . '>' |
||||
42 | . $item->getIcon() . ' ' . $item->title . '</a></li>' . PHP_EOL; |
||||
0 ignored issues
–
show
The property
title does not exist on KyleMassacre\Menus\Contracts\MenuItemContract . Since you implemented __get , consider adding a @property annotation.
![]() |
|||||
43 | } |
||||
44 | |||||
45 | /** |
||||
46 | * {@inheritdoc} |
||||
47 | */ |
||||
48 | public function getActiveState(MenuItemContract $item, string $state = ' class="active"'): mixed |
||||
49 | { |
||||
50 | return $item->isActive() ? $state : null; |
||||
51 | } |
||||
52 | |||||
53 | /** |
||||
54 | * Get active state on child items. |
||||
55 | * |
||||
56 | * @param MenuItemContract $item |
||||
57 | * @param string $state |
||||
58 | * |
||||
59 | * @return null|string |
||||
60 | */ |
||||
61 | public function getActiveStateOnChild(MenuItemContract $item, string $state = 'active'): ?string |
||||
62 | { |
||||
63 | return $item->hasActiveOnChild() ? $state : null; |
||||
64 | } |
||||
65 | |||||
66 | /** |
||||
67 | * {@inheritdoc} |
||||
68 | */ |
||||
69 | public function getDividerWrapper(): ?string |
||||
70 | { |
||||
71 | return '<li class="divider"></li>'; |
||||
72 | } |
||||
73 | |||||
74 | /** |
||||
75 | * {@inheritdoc} |
||||
76 | */ |
||||
77 | public function getHeaderWrapper(MenuItemContract $item): ?string |
||||
78 | { |
||||
79 | return '<li class="dropdown-header">' . $item->title . '</li>'; |
||||
0 ignored issues
–
show
The property
title does not exist on KyleMassacre\Menus\Contracts\MenuItemContract . Since you implemented __get , consider adding a @property annotation.
![]() |
|||||
80 | } |
||||
81 | |||||
82 | /** |
||||
83 | * {@inheritdoc} |
||||
84 | */ |
||||
85 | public function getMenuWithDropDownWrapper(MenuItemContract $item): ?string |
||||
86 | { |
||||
87 | $id = Str::random(); |
||||
88 | |||||
89 | return ' |
||||
90 | <li class="' . $this->getActiveStateOnChild($item) . ' panel panel-default" id="dropdown"> |
||||
91 | <a data-toggle="collapse" href="#' . $id . '"> |
||||
92 | ' . $item->getIcon() . ' ' . $item->title . ' <span class="caret"></span> |
||||
0 ignored issues
–
show
The property
title does not exist on KyleMassacre\Menus\Contracts\MenuItemContract . Since you implemented __get , consider adding a @property annotation.
![]() The call to
KyleMassacre\Menus\Contr...ItemContract::getIcon() has too few arguments starting with default .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above. ![]() |
|||||
93 | </a> |
||||
94 | <div id="' . $id . '" class="panel-collapse collapse ' . $this->getActiveStateOnChild($item, 'in') . '"> |
||||
95 | <div class="panel-body"> |
||||
96 | <ul class="nav navbar-nav"> |
||||
97 | ' . $this->getChildMenuItems($item) . ' |
||||
98 | </ul> |
||||
99 | </div> |
||||
100 | </div> |
||||
101 | </li> |
||||
102 | ' . PHP_EOL; |
||||
103 | } |
||||
104 | |||||
105 | /** |
||||
106 | * Get multilevel menu wrapper. |
||||
107 | * |
||||
108 | * @param MenuItemContract $item |
||||
109 | * |
||||
110 | * @return string |
||||
111 | */ |
||||
112 | public function getMultiLevelDropdownWrapper(MenuItemContract $item): string |
||||
113 | { |
||||
114 | return $this->getMenuWithDropDownWrapper($item); |
||||
115 | } |
||||
116 | } |
||||
117 |
This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.