Conditions | 25 |
Paths | 4398 |
Total Lines | 102 |
Code Lines | 60 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
Bugs | 1 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
183 | protected function addLink($menu, $menuLink, $isInSubMenu = false, $checkCapacity = true) |
||
184 | { |
||
185 | // Retrieve module if defined |
||
186 | $module = isset($menuLink->module) ? ucmodule($menuLink->module) : null; |
||
187 | |||
188 | //TODO: Check needed capacity |
||
189 | if ($menuLink->type === 'module' && !is_null($module)) { |
||
190 | // Don't display domain module if multi domains is not activated |
||
191 | if ($module->name === 'domain' && !env('UCCELLO_MULTI_DOMAINS', true)) { |
||
192 | return; |
||
193 | } |
||
194 | |||
195 | if (!$module->isActiveOnDomain($this->domain)) { |
||
196 | return; |
||
197 | } |
||
198 | if ($checkCapacity && !auth()->user()->canRetrieve($this->domain, $module)) { |
||
199 | return; |
||
200 | } |
||
201 | } |
||
202 | |||
203 | if (!empty($menuLink->module)) { |
||
204 | if (!in_array($menuLink->module, $this->menuAddedModules)) { |
||
205 | $this->menuAddedModules[ ] = $menuLink->module; |
||
206 | } |
||
207 | } |
||
208 | |||
209 | // Url |
||
210 | if (!empty($menuLink->url)) { // Prioritary to be compatible with addActiveModuleIfNotInMenu() |
||
211 | $url = $menuLink->url; |
||
212 | } elseif (!empty($menuLink->route) && !is_null($module)) { |
||
213 | $url = ucroute($menuLink->route, $this->domain, $module); |
||
214 | } else { |
||
215 | $url = 'javascript:void(0)'; |
||
216 | } |
||
217 | |||
218 | // Label |
||
219 | $label = $menuLink->type === 'module' ? uctrans($menuLink->label, $module) : uctrans($menuLink->label, $this->module); |
||
220 | if (!is_string($label)) { |
||
221 | return; |
||
222 | } |
||
223 | |||
224 | // Icon |
||
225 | if ($menuLink->type === 'folder') { |
||
226 | $fallbackIcon = 'folder'; |
||
227 | } elseif ($menuLink->type === 'link') { |
||
228 | $fallbackIcon = 'link'; |
||
229 | } else { |
||
230 | $fallbackIcon = 'extension'; |
||
231 | } |
||
232 | |||
233 | $icon = $menuLink->icon ?? $fallbackIcon; |
||
234 | |||
235 | // Is active. If the current route is in the menu, compare also the routes |
||
236 | if ($menuLink->type === 'module' && !is_null($module)) { |
||
237 | if ($this->isCurrentRouteInMenu($module)) { |
||
238 | $isActive = $this->module->id === $module->id && request()->route()->getName() === $menuLink->route; |
||
239 | } else { |
||
240 | $isActive = $this->module->id === $module->id; |
||
241 | } |
||
242 | } else { |
||
243 | $isActive = false; |
||
244 | } |
||
245 | |||
246 | // Add children |
||
247 | if (!empty($menuLink->children)) { |
||
248 | |||
249 | // Make a sub menu |
||
250 | $subMenu = Menu::new(); |
||
251 | |||
252 | // Add all links in the sub menu |
||
253 | foreach ($menuLink->children as $subMenuLink) { |
||
254 | $this->addLink($subMenu, $subMenuLink, true); // Recursive |
||
255 | } |
||
256 | |||
257 | if ($subMenu->count() > 0) { |
||
258 | $link = Html::raw( |
||
259 | '<ul class="collapsible collapsible-accordion">'. |
||
260 | '<li class="submenu">'. |
||
261 | '<a href="'.$url.'" class="collapsible-header waves-effect" tabindex="0">'. |
||
262 | '<i class="material-icons">'.$icon.'</i>'. |
||
263 | '<span>'.$label.'</span>'. |
||
264 | '</a>'. |
||
265 | '<div class="collapsible-body">'. |
||
266 | $subMenu->toHtml(). |
||
267 | '</div>'. |
||
268 | '</li>'. |
||
269 | '</ul>' |
||
270 | ); |
||
271 | |||
272 | $menu->add($link); |
||
273 | } |
||
274 | |||
275 | } else { |
||
276 | $link = Html::raw( |
||
277 | '<a href="'.$url.'">'. |
||
278 | '<i class="material-icons">'.$icon.'</i>'. |
||
279 | '<span>'.$label.'</span>'. |
||
280 | '</a>' |
||
281 | )->setActive($isActive); |
||
282 | |||
283 | // Add link to menu |
||
284 | $menu->add($link); |
||
285 | } |
||
366 | } |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths