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