| Conditions | 5 |
| Paths | 4 |
| Total Lines | 55 |
| Code Lines | 27 |
| 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 |
||
| 72 | function xoops_module_install_wfdownloads(XoopsModule $module) |
||
|
|
|||
| 73 | { |
||
| 74 | global $xoopsModule; |
||
| 75 | require_once dirname(__DIR__, 3) . '/mainfile.php'; |
||
| 76 | require_once __DIR__ . '/common.php'; |
||
| 77 | |||
| 78 | // $moduleDirName = $xoopsModule->getVar('dirname'); |
||
| 79 | $moduleDirName = basename(dirname(__DIR__)); |
||
| 80 | xoops_loadLanguage('admin', $moduleDirName); |
||
| 81 | xoops_loadLanguage('modinfo', $moduleDirName); |
||
| 82 | |||
| 83 | // $configurator = require __DIR__ . '/config.php'; |
||
| 84 | $configurator = new Configurator(); |
||
| 85 | $utility = new Utility(); |
||
| 86 | |||
| 87 | // default Permission Settings |
||
| 88 | $module_id = $xoopsModule->getVar('mid'); |
||
| 89 | $module_name = $xoopsModule->getVar('name'); |
||
| 90 | $module_dirname = $xoopsModule->getVar('dirname'); |
||
| 91 | $module_version = $xoopsModule->getVar('version'); |
||
| 92 | /** @var \XoopsGroupPermHandler $grouppermHandler */ |
||
| 93 | $grouppermHandler = xoops_getHandler('groupperm'); |
||
| 94 | // access rights |
||
| 95 | $grouppermHandler->addRight('nw_approve', 1, XOOPS_GROUP_ADMIN, $module_id); |
||
| 96 | $grouppermHandler->addRight('nw_submit', 1, XOOPS_GROUP_ADMIN, $module_id); |
||
| 97 | $grouppermHandler->addRight('nw_view', 1, XOOPS_GROUP_ADMIN, $module_id); |
||
| 98 | $grouppermHandler->addRight('nw_view', 1, XOOPS_GROUP_USERS, $module_id); |
||
| 99 | $grouppermHandler->addRight('nw_view', 1, XOOPS_GROUP_ANONYMOUS, $module_id); |
||
| 100 | |||
| 101 | // --- CREATE FOLDERS --------------- |
||
| 102 | /* |
||
| 103 | if (count($configurator['uploadFolders']) > 0) { |
||
| 104 | // foreach (array_keys($GLOBALS['uploadFolders']) as $i) { |
||
| 105 | foreach (array_keys($configurator['uploadFolders']) as $i) { |
||
| 106 | $utility::createFolder($configurator['uploadFolders'][$i]); |
||
| 107 | } |
||
| 108 | } |
||
| 109 | */ |
||
| 110 | if (count($configurator->uploadFolders) > 0) { |
||
| 111 | // foreach (array_keys($GLOBALS['uploadFolders']) as $i) { |
||
| 112 | foreach (array_keys($configurator->uploadFolders) as $i) { |
||
| 113 | $utility::createFolder($configurator->uploadFolders[$i]); |
||
| 114 | } |
||
| 115 | } |
||
| 116 | |||
| 117 | // --- COPY blank.png FILES --------------- |
||
| 118 | if (count($configurator->copyBlankFiles) > 0) { |
||
| 119 | $file = dirname(__DIR__) . '/assets/images/blank.png'; |
||
| 120 | foreach (array_keys($configurator->copyBlankFiles) as $i) { |
||
| 121 | $dest = $configurator->copyBlankFiles[$i] . '/blank.png'; |
||
| 122 | $utility::copyFile($file, $dest); |
||
| 123 | } |
||
| 124 | } |
||
| 125 | |||
| 126 | return true; |
||
| 127 | } |
||
| 199 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.