| Conditions | 13 |
| Paths | 768 |
| Total Lines | 59 |
| Code Lines | 47 |
| 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 |
||
| 78 | public function retrieveBlocks() |
||
| 79 | { |
||
| 80 | global $xoopsConfig; |
||
| 81 | $xoopsPreload = XoopsPreload::getInstance(); |
||
| 82 | |||
| 83 | $startMod = ($xoopsConfig['startpage'] == '--') ? 'system' : $xoopsConfig['startpage']; |
||
| 84 | if (isset($GLOBALS['xoopsModule']) && is_object($GLOBALS['xoopsModule'])) { |
||
| 85 | list($mid, $dirname) = array( |
||
| 86 | $GLOBALS['xoopsModule']->getVar('mid'), |
||
| 87 | $GLOBALS['xoopsModule']->getVar('dirname')); |
||
| 88 | $isStart = (substr($_SERVER['PHP_SELF'], -9) === 'index.php' && $xoopsConfig['startpage'] == $dirname && empty($_SERVER['QUERY_STRING'])); |
||
| 89 | } else { |
||
| 90 | list($mid, $dirname) = array( |
||
| 91 | 0, |
||
| 92 | 'system'); |
||
| 93 | $isStart = !empty($GLOBALS['xoopsOption']['show_cblock']); |
||
| 94 | } |
||
| 95 | |||
| 96 | $groups = (isset($GLOBALS['xoopsUser']) && is_object($GLOBALS['xoopsUser'])) ? $GLOBALS['xoopsUser']->getGroups() : array( |
||
| 97 | XOOPS_GROUP_ANONYMOUS); |
||
| 98 | |||
| 99 | $oldzones = array( |
||
| 100 | XOOPS_SIDEBLOCK_LEFT => 'canvas_left', |
||
| 101 | XOOPS_SIDEBLOCK_RIGHT => 'canvas_right', |
||
| 102 | XOOPS_CENTERBLOCK_LEFT => 'page_topleft', |
||
| 103 | XOOPS_CENTERBLOCK_CENTER => 'page_topcenter', |
||
| 104 | XOOPS_CENTERBLOCK_RIGHT => 'page_topright', |
||
| 105 | XOOPS_CENTERBLOCK_BOTTOMLEFT => 'page_bottomleft', |
||
| 106 | XOOPS_CENTERBLOCK_BOTTOM => 'page_bottomcenter', |
||
| 107 | XOOPS_CENTERBLOCK_BOTTOMRIGHT => 'page_bottomright', |
||
| 108 | XOOPS_FOOTERBLOCK_LEFT => 'footer_left', |
||
| 109 | XOOPS_FOOTERBLOCK_RIGHT => 'footer_right', |
||
| 110 | XOOPS_FOOTERBLOCK_CENTER => 'footer_center', |
||
| 111 | XOOPS_FOOTERBLOCK_ALL => 'footer_all'); |
||
| 112 | |||
| 113 | foreach ($oldzones as $zone) { |
||
| 114 | $this->blocks[$zone] = array(); |
||
| 115 | } |
||
| 116 | if ($this->theme) { |
||
| 117 | $template =& $this->theme->template; |
||
| 118 | $backup = array( |
||
| 119 | $template->caching, |
||
| 120 | $template->cache_lifetime); |
||
| 121 | } else { |
||
| 122 | $template = null; |
||
| 123 | $template = new XoopsTpl(); |
||
| 124 | } |
||
| 125 | $xoopsblock = new XoopsBlock(); |
||
| 126 | $block_arr = array(); |
||
| 127 | $block_arr = $xoopsblock->getAllByGroupModule($groups, $mid, $isStart, XOOPS_BLOCK_VISIBLE); |
||
| 128 | $xoopsPreload->triggerEvent('core.class.theme_blocks.retrieveBlocks', array(&$this, &$template, &$block_arr)); |
||
| 129 | foreach ($block_arr as $block) { |
||
| 130 | $side = $oldzones[$block->getVar('side')]; |
||
| 131 | if ($var = $this->buildBlock($block, $template)) { |
||
| 132 | $this->blocks[$side][$var['id']] = $var; |
||
| 133 | } |
||
| 134 | } |
||
| 135 | if ($this->theme) { |
||
| 136 | list($template->caching, $template->cache_lifetime) = $backup; |
||
| 137 | } |
||
| 245 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.