| Conditions | 7 |
| Paths | 16 |
| Total Lines | 82 |
| Code Lines | 33 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| 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 declare(strict_types=1); |
||
| 57 | function xoops_module_install_adslight(\XoopsModule $module): bool |
||
|
|
|||
| 58 | { |
||
| 59 | require_once \dirname(__DIR__, 3) . '/mainfile.php'; |
||
| 60 | |||
| 61 | global $xoopsDB; |
||
| 62 | // $moduleDirName = $module->getVar('dirname'); |
||
| 63 | $moduleDirName = \basename(\dirname(__DIR__)); |
||
| 64 | xoops_loadLanguage('admin', $moduleDirName); |
||
| 65 | xoops_loadLanguage('modinfo', $moduleDirName); |
||
| 66 | |||
| 67 | // $configurator = require_once __DIR__ . '/config.php'; |
||
| 68 | $configurator = new Configurator(); |
||
| 69 | $utility = new Utility(); |
||
| 70 | |||
| 71 | /* |
||
| 72 | |||
| 73 | // default Permission Settings ---------------------- |
||
| 74 | $moduleId = $module->getVar('mid'); |
||
| 75 | // $module_name = $module->getVar('name'); |
||
| 76 | // $module_dirname = $module->getVar('dirname'); |
||
| 77 | // $module_version = $module->getVar('version'); |
||
| 78 | $grouppermHandler = xoops_getHandler('groupperm'); |
||
| 79 | // access rights ------------------------------------------ |
||
| 80 | $grouppermHandler->addRight($moduleDirName . '_premium', 1, XOOPS_GROUP_ADMIN, $moduleId); |
||
| 81 | $grouppermHandler->addRight($moduleDirName . '_submit', 1, XOOPS_GROUP_ADMIN, $moduleId); |
||
| 82 | $grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_ADMIN, $moduleId); |
||
| 83 | $grouppermHandler->addRight($moduleDirName . '_submit', 1, XOOPS_GROUP_USERS, $moduleId); |
||
| 84 | $grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_USERS, $moduleId); |
||
| 85 | $grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_ANONYMOUS, $moduleId); |
||
| 86 | |||
| 87 | $sql = 'SELECT COUNT(*) FROM ' . $xoopsDB->prefix('adslight_categories'); |
||
| 88 | $result8 = $xoopsDB->query($sql); |
||
| 89 | $sql = 'SELECT * FROM ' . $xoopsDB->prefix('adslight_categories') . ''; |
||
| 90 | $rowsCount = $xoopsDB->getRowsNum($xoopsDB->query($sql)); |
||
| 91 | |||
| 92 | |||
| 93 | |||
| 94 | $utility::saveCategoryPermissions($groups, $categoryId, $permName); |
||
| 95 | */ |
||
| 96 | |||
| 97 | $groups1 = [XOOPS_GROUP_ADMIN]; |
||
| 98 | $groups2 = [XOOPS_GROUP_ADMIN, XOOPS_GROUP_USERS]; |
||
| 99 | $groups3 = [XOOPS_GROUP_ADMIN, XOOPS_GROUP_USERS, XOOPS_GROUP_ANONYMOUS]; |
||
| 100 | |||
| 101 | $permName1 = $moduleDirName . '_premium'; |
||
| 102 | $permName2 = $moduleDirName . '_submit'; |
||
| 103 | $permName3 = $moduleDirName . '_view'; |
||
| 104 | |||
| 105 | $sql = 'SELECT * FROM ' . $xoopsDB->prefix('adslight_categories') . ' '; |
||
| 106 | $rowsCount = $xoopsDB->getRowsNum($xoopsDB->query($sql)); |
||
| 107 | |||
| 108 | $sql = 'SELECT cid FROM ' . $xoopsDB->prefix('adslight_categories'); |
||
| 109 | $result = $xoopsDB->query($sql); |
||
| 110 | if (!$xoopsDB->isResultSet($result)) { |
||
| 111 | \trigger_error("Query Failed! SQL: $sql- Error: " . $xoopsDB->error(), E_USER_ERROR); |
||
| 112 | } |
||
| 113 | |||
| 114 | while (false !== ($myrow = $xoopsDB->fetchArray($result))) { |
||
| 115 | $categoryId = (int)$myrow['cid']; |
||
| 116 | $utility::saveCategoryPermissions($groups1, $categoryId, $permName1); |
||
| 117 | $utility::saveCategoryPermissions($groups2, $categoryId, $permName2); |
||
| 118 | $utility::saveCategoryPermissions($groups3, $categoryId, $permName3); |
||
| 119 | } |
||
| 120 | |||
| 121 | // --- CREATE FOLDERS --------------- |
||
| 122 | if (count($configurator->uploadFolders) > 0) { |
||
| 123 | // foreach (array_keys($GLOBALS['uploadFolders']) as $i) { |
||
| 124 | foreach (array_keys($configurator->uploadFolders) as $i) { |
||
| 125 | $utility::createFolder($configurator->uploadFolders[$i]); |
||
| 126 | } |
||
| 127 | } |
||
| 128 | |||
| 129 | // --- COPY blank.png FILES --------------- |
||
| 130 | if (count($configurator->copyBlankFiles) > 0) { |
||
| 131 | $file = \dirname(__DIR__) . '/assets/images/blank.png'; |
||
| 132 | foreach (array_keys($configurator->copyBlankFiles) as $i) { |
||
| 133 | $dest = $configurator->copyBlankFiles[$i] . '/blank.png'; |
||
| 134 | $utility::copyFile($file, $dest); |
||
| 135 | } |
||
| 136 | } |
||
| 137 | |||
| 138 | return true; |
||
| 139 | } |
||
| 140 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.