Conditions | 10 |
Paths | 6 |
Total Lines | 29 |
Code Lines | 18 |
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 declare(strict_types=1); |
||
22 | function myiframe_getmoduleoption($option, $repmodule = 'myiframe') |
||
23 | { |
||
24 | global $xoopsModuleConfig, $xoopsModule; |
||
25 | static $tbloptions = []; |
||
26 | if (is_array($tbloptions) && array_key_exists($option, $tbloptions)) { |
||
27 | return $tbloptions[$option]; |
||
28 | } |
||
29 | |||
30 | $retval = false; |
||
31 | if (isset($xoopsModuleConfig) && (is_object($xoopsModule) && $xoopsModule->getVar('dirname') == $repmodule && $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($repmodule); |
||
39 | /** @var \XoopsConfigHandler $configHandler */ |
||
40 | $configHandler = xoops_getHandler('config'); |
||
41 | if ($module) { |
||
42 | $moduleConfig = $configHandler->getConfigsByCat(0, $module->getVar('mid')); |
||
43 | if (isset($moduleConfig[$option])) { |
||
44 | $retval = $moduleConfig[$option]; |
||
45 | } |
||
46 | } |
||
47 | } |
||
48 | $tbloptions[$option] = $retval; |
||
49 | |||
50 | return $retval; |
||
51 | } |
||
99 |