| Conditions | 9 | 
| Paths | 144 | 
| Total Lines | 51 | 
| Code Lines | 29 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 2 | ||
| Bugs | 0 | 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  | 
            ||
| 91 | public function links(  | 
            ||
| 92 | RequestStack $requestStack,  | 
            ||
| 93 | ExtensionRepositoryInterface $extensionRepository,  | 
            ||
| 94 | ExtensionMenuCollector $extensionMenuCollector  | 
            ||
| 95 |     ): Response { | 
            ||
| 96 | /** @var Request $masterRequest */  | 
            ||
| 97 | $masterRequest = $requestStack->getMasterRequest();  | 
            ||
| 98 | /** @var Request $currentRequest */  | 
            ||
| 99 | $currentRequest = $requestStack->getCurrentRequest();  | 
            ||
| 100 | $caller = $masterRequest->attributes->all();  | 
            ||
| 101 | $caller['info'] = !empty($caller['_zkModule']) ? $extensionRepository->get($caller['_zkModule']) : [];  | 
            ||
| 102 | // your own links array  | 
            ||
| 103 |         $links = '' !== $currentRequest->attributes->get('links') ? $currentRequest->attributes->get('links') : ''; | 
            ||
| 104 | // you can pass module name you want to get links for  | 
            ||
| 105 |         $moduleName = '' !== $currentRequest->attributes->get('modname') | 
            ||
| 106 |             ? $currentRequest->attributes->get('modname') | 
            ||
| 107 | : ($caller['_zkModule'] ?? '');  | 
            ||
| 108 | |||
| 109 | // no own links array  | 
            ||
| 110 |         if (empty($links)) { | 
            ||
| 111 | // define type - default  | 
            ||
| 112 | $linksType = 'user';  | 
            ||
| 113 | // detect from masterRequest  | 
            ||
| 114 |             $linksType = '' !== $masterRequest->attributes->get('type') ? $masterRequest->attributes->get('type') : $linksType; | 
            ||
| 115 | // passed to currentRequest most important  | 
            ||
| 116 |             $linksType = '' !== $currentRequest->attributes->get('type') ? $currentRequest->attributes->get('type') : $linksType; | 
            ||
| 117 | // get the menu links  | 
            ||
| 118 | $extensionMenu = $extensionMenuCollector->get($moduleName, $linksType);  | 
            ||
| 119 |             if (isset($extensionMenu)) { | 
            ||
| 120 |                 $extensionMenu->setChildrenAttribute('class', 'nav nav-modulelinks'); | 
            ||
| 121 | }  | 
            ||
| 122 | }  | 
            ||
| 123 | |||
| 124 | // menu css  | 
            ||
| 125 | $menu_css = [  | 
            ||
| 126 |             'menuId' => $currentRequest->attributes->get('menuid', ''), | 
            ||
| 127 |             'menuClass' => $currentRequest->attributes->get('menuclass', ''), | 
            ||
| 128 |             'menuItemClass' => $currentRequest->attributes->get('itemclass', ''), | 
            ||
| 129 |             'menuFirstItemClass' => $currentRequest->attributes->get('first', ''), | 
            ||
| 130 |             'menuLastItemClass' => $currentRequest->attributes->get('last', '') | 
            ||
| 131 | ];  | 
            ||
| 132 | |||
| 133 |         $template = '' !== $currentRequest->attributes->get('template') | 
            ||
| 134 |             ? $currentRequest->attributes->get('template') | 
            ||
| 135 | : '@ZikulaExtensionsModule/ExtensionsInterface/links.html.twig';  | 
            ||
| 136 | |||
| 137 | return $this->render($template, [  | 
            ||
| 138 | 'caller' => $caller,  | 
            ||
| 139 | 'menu_css' => $menu_css,  | 
            ||
| 140 | 'extensionMenu' => $extensionMenu,  | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 141 | 'current_path' => $masterRequest->getPathInfo()  | 
            ||
| 142 | ]);  | 
            ||
| 145 |