| Conditions | 17 |
| Paths | 771 |
| Total Lines | 134 |
| Code Lines | 75 |
| 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 |
||
| 33 | function mymenus_block_show($options) |
||
| 34 | { |
||
| 35 | global $xoopsTpl, $xoopsLogger; |
||
| 36 | /** @var \XoopsModules\Mymenus\Helper $helper */ |
||
| 37 | $helper = \XoopsModules\Mymenus\Helper::getInstance(); |
||
| 38 | |||
| 39 | $block = []; |
||
| 40 | $xoopsLogger->startTime('My Menus Block'); |
||
| 41 | $myts = \MyTextSanitizer::getInstance(); |
||
| 42 | |||
| 43 | $registry = Mymenus\Registry::getInstance(); |
||
| 44 | $plugin = Mymenus\Plugin::getInstance(); |
||
| 45 | $plugin->triggerEvent('Boot'); |
||
| 46 | |||
| 47 | $mid = $options[0]; |
||
| 48 | |||
| 49 | $linksCriteria = new \CriteriaCompo(new \Criteria('mid', $mid)); |
||
| 50 | $linksCriteria->setSort('weight'); |
||
| 51 | $linksCriteria->setOrder('ASC'); |
||
| 52 | //get menu links as an array with ids as keys |
||
| 53 | $linksArray = $helper->getHandler('Links')->getAll($linksCriteria, null, false, false); // as array |
||
| 54 | unset($linksCriteria); |
||
| 55 | |||
| 56 | foreach ($linksArray as $key => $links) { |
||
| 57 | $registry->setEntry('menu', $links); |
||
| 58 | $registry->setEntry('has_access', 'yes'); |
||
| 59 | $plugin->triggerEvent('HasAccess'); |
||
| 60 | if ('no' === $registry->getEntry('has_access')) { |
||
| 61 | unset($linksArray[$key]); |
||
| 62 | } |
||
| 63 | } |
||
| 64 | |||
| 65 | $linksCount = count($linksArray); |
||
| 66 | if (0 === $linksCount) { |
||
| 67 | return $block; |
||
| 68 | } |
||
| 69 | |||
| 70 | foreach ($linksArray as $key => $links) { |
||
| 71 | $registry->setEntry('link_array', $links); |
||
| 72 | $plugin->triggerEvent('TitleDecoration'); |
||
| 73 | $plugin->triggerEvent('AlttitleDecoration'); |
||
| 74 | $plugin->triggerEvent('LinkDecoration'); |
||
| 75 | $plugin->triggerEvent('ImageDecoration'); |
||
| 76 | $linksArray[$key] = $registry->getEntry('link_array'); |
||
| 77 | } |
||
| 78 | $registry->setEntry('menus', $linksArray); |
||
| 79 | $plugin->triggerEvent('End'); |
||
| 80 | $linksArray = $registry->getEntry('menus'); |
||
| 81 | |||
| 82 | $menuBuilder = new Mymenus\Builder($linksArray); |
||
| 83 | $block = $menuBuilder->render(); |
||
| 84 | |||
| 85 | /*--------------------------------------------------------------*/ |
||
| 86 | // Default files to load |
||
| 87 | $cssArray = []; |
||
| 88 | $jsArray = []; |
||
| 89 | |||
| 90 | // Get extra files from skins |
||
| 91 | $skinInfo = Utility::getSkinInfo($options[1], $options[2], isset($options[5]) ? $options[5] : ''); |
||
| 92 | |||
| 93 | // |
||
| 94 | if (isset($skinInfo['css'])) { |
||
| 95 | $cssArray = array_merge($cssArray, $skinInfo['css']); |
||
| 96 | } |
||
| 97 | if (isset($skinInfo['js'])) { |
||
| 98 | $jsArray = array_merge($jsArray, $skinInfo['js']); |
||
| 99 | } |
||
| 100 | // |
||
| 101 | if ('xoopstpl' === $helper->getConfig('assign_method')) { |
||
| 102 | $tpl_vars = ''; |
||
| 103 | foreach ($cssArray as $file) { |
||
| 104 | $tpl_vars .= "\n<link rel='stylesheet' type='text/css' media='all' href='{$file}'>"; |
||
| 105 | } |
||
| 106 | foreach ($jsArray as $file) { |
||
| 107 | $tpl_vars .= "\n<script type='text/javascript' src='{$file}'></script>"; |
||
| 108 | } |
||
| 109 | if (isset($skinInfo['header'])) { |
||
| 110 | $tpl_vars .= "\n{$skinInfo['header']}"; |
||
| 111 | } |
||
| 112 | $GLOBALS['xoopsTpl']->assign('xoops_module_header', $tpl_vars . @$GLOBALS['xoopsTpl']->get_template_vars('xoops_module_header')); |
||
| 113 | } else { |
||
| 114 | foreach ($cssArray as $file) { |
||
| 115 | $GLOBALS['xoTheme']->addStylesheet($file); |
||
| 116 | } |
||
| 117 | foreach ($jsArray as $file) { |
||
| 118 | $GLOBALS['xoTheme']->addScript($file); |
||
| 119 | } |
||
| 120 | if (isset($skinInfo['header'])) { |
||
| 121 | $GLOBALS['xoopsTpl']->assign('xoops_footer', @$GLOBALS['xoopsTpl']->get_template_vars('xoops_footer') . "\n" . $skinInfo['header']); |
||
| 122 | } |
||
| 123 | } |
||
| 124 | // |
||
| 125 | $blockTpl = new \XoopsTpl(); |
||
| 126 | $blockTpl->assign([ |
||
| 127 | 'block' => $block, |
||
| 128 | 'config' => $skinInfo['config'], |
||
| 129 | 'skinurl' => $skinInfo['url'], |
||
| 130 | 'skinpath' => $skinInfo['path'], |
||
| 131 | 'xlanguage' => xoops_isActiveModule('xlanguage') ? true : false // xLanguage check |
||
| 132 | ]); |
||
| 133 | // Assign ul class |
||
| 134 | $menusObj = $helper->getHandler('Menus')->get($mid); |
||
| 135 | $blockTpl->assign('menucss', $menusObj->getVar('css')); |
||
| 136 | /* |
||
| 137 | $menuCss = ''; |
||
| 138 | $menusHandler = $helper->getHandler('menus', 'mymenus'); |
||
| 139 | $menuCriteria = new \CriteriaCompo(new \Criteria('id', $mid)); |
||
| 140 | $menuArray = $menusHandler->getAll($menuCriteria, null, false, false); |
||
| 141 | |||
| 142 | if (is_array($menuArray) && (count($menuArray) > 0)) { |
||
| 143 | foreach ($menuArray as $menu) { |
||
| 144 | $menuCss = isset($menu['css']) ? "{$menu['css']} " : ''; |
||
| 145 | } |
||
| 146 | $menuCss = trim($menuCss); |
||
| 147 | } |
||
| 148 | if (!($menuCss)) { |
||
| 149 | $menuCss = ""; |
||
| 150 | } else { |
||
| 151 | $menuCss = implode(' ', $menuCss); |
||
| 152 | } |
||
| 153 | $blockTpl->assign('menucss', $menuCss); |
||
| 154 | */ |
||
| 155 | $block['content'] = $blockTpl->fetch($skinInfo['template']); |
||
| 156 | |||
| 157 | if ('template' === $options[3]) { |
||
| 158 | $GLOBALS['xoopsTpl']->assign($helper->getConfig('unique_id_prefix') . $options[4], $block['content']); |
||
| 159 | $block = false; |
||
| 160 | } |
||
| 161 | |||
| 162 | $registry->unsetAll(); |
||
| 163 | unset($registry, $plugin); |
||
| 164 | $xoopsLogger->stopTime('My Menus Block'); |
||
| 165 | |||
| 166 | return $block; |
||
| 167 | } |
||
| 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