Conditions | 10 |
Paths | 6 |
Total Lines | 33 |
Code Lines | 20 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
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 |
||
20 | function gal_getmoduleoption($option) |
||
21 | { |
||
22 | global $xoopsModuleConfig, $xoopsModule; |
||
23 | static $tbloptions = []; |
||
24 | if (is_array($tbloptions) && array_key_exists($option, $tbloptions)) { |
||
25 | return $tbloptions[$option]; |
||
26 | } |
||
27 | |||
28 | $retval = false; |
||
29 | if (isset($xoopsModuleConfig) |
||
30 | && (is_object($xoopsModule) && 'extgallery' === $xoopsModule->getVar('dirname') |
||
31 | && $xoopsModule->getVar('isactive'))) { |
||
32 | if (isset($xoopsModuleConfig[$option])) { |
||
33 | $retval = $xoopsModuleConfig[$option]; |
||
34 | } |
||
35 | } else { |
||
36 | /** @var \XoopsModuleHandler $moduleHandler */ |
||
37 | $moduleHandler = xoops_getHandler('module'); |
||
38 | $module = $moduleHandler->getByDirname('extgallery'); |
||
39 | |||
40 | /** @var \XoopsModuleHandler $moduleHandler */ |
||
41 | /** @var \XoopsConfigHandler $configHandler */ |
||
42 | $configHandler = xoops_getHandler('config'); |
||
43 | if ($module) { |
||
44 | $moduleConfig = $configHandler->getConfigsByCat(0, $module->getVar('mid')); |
||
45 | if (isset($moduleConfig[$option])) { |
||
46 | $retval = $moduleConfig[$option]; |
||
47 | } |
||
48 | } |
||
49 | } |
||
50 | $tbloptions[$option] = $retval; |
||
51 | |||
52 | return $retval; |
||
53 | } |
||
84 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.