| Conditions | 10 |
| Paths | 19 |
| Total Lines | 80 |
| Code Lines | 59 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 174 | function mymenus_block_edit($options) |
||
| 175 | { |
||
| 176 | /** @var \XoopsModules\Mymenus\Helper $helper */ |
||
| 177 | $helper = \XoopsModules\Mymenus\Helper::getInstance(); |
||
| 178 | // |
||
| 179 | xoops_loadLanguage('admin', 'mymenus'); |
||
| 180 | xoops_load('XoopsFormLoader'); |
||
| 181 | // option 0: menu |
||
| 182 | $menusCriteria = new \CriteriaCompo(); |
||
| 183 | $menusCriteria->setSort('title'); |
||
| 184 | $menusCriteria->setOrder('ASC'); |
||
| 185 | $menusList = $helper->getHandler('Menus')->getList($menusCriteria); |
||
| 186 | unset($menusCriteria); |
||
| 187 | if (0 === count($menusList)) { |
||
| 188 | $form = "<a href='" . $GLOBALS['xoops']->url("modules/{$helper->getDirname()}/admin/menus.php") . "'>" . _AM_MYMENUS_MSG_NOMENUS . "</a>\n"; |
||
| 189 | |||
| 190 | return $form; |
||
| 191 | } |
||
| 192 | $form = '<b>' . _MB_MYMENUS_SELECT_MENU . '</b> '; |
||
| 193 | $formMenusSelect = new \XoopsFormSelect('', 'options[0]', $options[0], 1, false); |
||
| 194 | $formMenusSelect->addOptionArray($menusList); |
||
| 195 | $form .= $formMenusSelect->render(); |
||
| 196 | $form .= "</select>\n <i>" . _MB_MYMENUS_SELECT_MENU_DSC . "</i>\n<br><br>\n"; |
||
| 197 | // option 1: moduleSkin |
||
| 198 | xoops_load('XoopsLists'); |
||
| 199 | $tempModuleSkinsList = \XoopsLists::getDirListAsArray($GLOBALS['xoops']->path("modules/{$helper->getDirname()}/skins/")); |
||
| 200 | $moduleSkinsList = []; |
||
| 201 | foreach ($tempModuleSkinsList as $key => $moduleSkin) { |
||
| 202 | if (file_exists($GLOBALS['xoops']->path("modules/{$helper->getDirname()}/skins/{$moduleSkin}/skin_version.php"))) { |
||
| 203 | $moduleSkinsList[$moduleSkin] = $moduleSkin; |
||
| 204 | } |
||
| 205 | } |
||
| 206 | $form .= '<b>' . _MB_MYMENUS_SELECT_SKIN . '</b> '; |
||
| 207 | $formModuleSkinSelect = new \XoopsFormSelect('', 'options[1]', $options[1], 1, false); |
||
| 208 | $formModuleSkinSelect->addOptionArray($moduleSkinsList); |
||
| 209 | $form .= $formModuleSkinSelect->render(); |
||
| 210 | $form .= "\n <i>" . _MB_MYMENUS_SELECT_SKIN_DSC . "</i>\n<br><br>\n"; |
||
| 211 | // option 2: useThemeSkin |
||
| 212 | $form .= '<b>' . _MB_MYMENUS_USE_THEME_SKIN . '</b> '; |
||
| 213 | $formUseThemeSkinRadio = new \XoopsFormRadioYN('', 'options[2]', $options[2]); |
||
| 214 | $form .= $formUseThemeSkinRadio->render(); |
||
| 215 | $form .= "\n <i>" . _MB_MYMENUS_USE_THEME_SKIN_DSC . "</i>\n<br><br>\n"; |
||
| 216 | // option 3: displayMethod |
||
| 217 | $displayMethodsList = [ |
||
| 218 | 'block' => _MB_MYMENUS_DISPLAY_METHOD_BLOCK, |
||
| 219 | 'template' => _MB_MYMENUS_DISPLAY_METHOD_TEMPLATE |
||
| 220 | ]; |
||
| 221 | $form .= '<b>' . _MB_MYMENUS_DISPLAY_METHOD . '</b> '; |
||
| 222 | $formDisplayMethodSelect = new \XoopsFormSelect('', 'options[3]', $options[3], 1); |
||
| 223 | $formDisplayMethodSelect->addOptionArray($displayMethodsList); |
||
| 224 | $form .= $formDisplayMethodSelect->render(); |
||
| 225 | $form .= "\n <i>" . sprintf(_MB_MYMENUS_DISPLAY_METHOD_DSC, $helper->getConfig('unique_id_prefix')) . "</i>\n<br><br>\n"; |
||
| 226 | // option 4: unique_id |
||
| 227 | if (!$options[4] || ('clone' === Request::getCmd('op', '', 'GET'))) { |
||
| 228 | $options[4] = time(); |
||
| 229 | } |
||
| 230 | $form .= '<b>' . _MB_MYMENUS_UNIQUEID . '</b> '; |
||
| 231 | $formUniqueIdText = new \XoopsFormText('', 'options[4]', 50, 255, $options[4]); |
||
| 232 | $form .= $formUniqueIdText->render(); |
||
| 233 | $form .= "\n <i>" . _MB_MYMENUS_UNIQUEID_DSC . "</i>\n<br><br>\n"; |
||
| 234 | // option 5: themeSkin |
||
| 235 | if (file_exists($GLOBALS['xoops']->path('/themes/' . $GLOBALS['xoopsConfig']['theme_set'] . "/modules/{$helper->getDirname()}/skins/"))) { |
||
| 236 | xoops_load('XoopsLists'); |
||
| 237 | $tempThemeSkinsList = \XoopsLists::getDirListAsArray($GLOBALS['xoops']->path('/themes/' . $GLOBALS['xoopsConfig']['theme_set'] . "/modules/{$helper->getDirname()}/skins/")); |
||
| 238 | if (isset($tempThemeSkinsList)) { |
||
| 239 | $themeSkinsList = []; |
||
| 240 | foreach ($tempThemeSkinsList as $key => $themeSkin) { |
||
| 241 | if (file_exists($GLOBALS['xoops']->path('/themes/' . $GLOBALS['xoopsConfig']['theme_set'] . "/modules/{$helper->getDirname()}/skins/{$themeSkin}/skin_version.php"))) { |
||
| 242 | $themeSkinsList[$themeSkin] = '/themes/' . $GLOBALS['xoopsConfig']['theme_set'] . "/modules/{$helper->getDirname()}/skins/{$themeSkin}"; |
||
| 243 | } |
||
| 244 | } |
||
| 245 | $form .= '<b>' . _MB_MYMENUS_SELECT_SKIN_FROM_THEME . '</b> '; |
||
| 246 | $formThemeSkinSelect = new \XoopsFormSelect('', 'options[5]', $options[5], 1, false); |
||
| 247 | $formThemeSkinSelect->addOptionArray($themeSkinsList); |
||
| 248 | $form .= $formThemeSkinSelect->render(); |
||
| 249 | $form .= "\n <i>" . _MB_MYMENUS_SELECT_SKIN_FROM_THEME_DSC . "</i>\n<br><br>\n"; |
||
| 250 | } |
||
| 251 | } |
||
| 252 | |||
| 253 | return $form; |
||
| 254 | } |
||
| 255 |
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