| Conditions | 7 |
| Paths | 8 |
| Total Lines | 58 |
| Code Lines | 30 |
| 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 |
||
| 63 | function xoops_module_install_cardealer(\XoopsModule $module) |
||
| 64 | { |
||
| 65 | $moduleDirName = basename(dirname(__DIR__)); |
||
| 66 | |||
| 67 | /** @var Cardealer\Helper $helper */ |
||
| 68 | /** @var Cardealer\Utility $utility */ |
||
| 69 | /** @var Common\Configurator $configurator */ |
||
| 70 | $helper = Cardealer\Helper::getInstance(); |
||
| 71 | $utility = new Cardealer\Utility(); |
||
| 72 | $configurator = new Common\Configurator(); |
||
| 73 | |||
| 74 | // Load language files |
||
| 75 | $helper->loadLanguage('admin'); |
||
| 76 | $helper->loadLanguage('modinfo'); |
||
| 77 | |||
| 78 | // default Permission Settings ---------------------- |
||
| 79 | $moduleId = $module->getVar('mid'); |
||
| 80 | $moduleId2 = $helper->getModule()->mid(); |
||
|
|
|||
| 81 | //$moduleName = $module->getVar('name'); |
||
| 82 | $gpermHandler = xoops_getHandler('groupperm'); |
||
| 83 | // access rights ------------------------------------------ |
||
| 84 | $gpermHandler->addRight($moduleDirName . '_approve', 1, XOOPS_GROUP_ADMIN, $moduleId); |
||
| 85 | $gpermHandler->addRight($moduleDirName . '_submit', 1, XOOPS_GROUP_ADMIN, $moduleId); |
||
| 86 | $gpermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_ADMIN, $moduleId); |
||
| 87 | $gpermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_USERS, $moduleId); |
||
| 88 | $gpermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_ANONYMOUS, $moduleId); |
||
| 89 | |||
| 90 | // --- CREATE FOLDERS --------------- |
||
| 91 | if (count($configurator->uploadFolders) > 0) { |
||
| 92 | // foreach (array_keys($GLOBALS['uploadFolders']) as $i) { |
||
| 93 | foreach (array_keys($configurator->uploadFolders) as $i) { |
||
| 94 | $utility::createFolder($configurator->uploadFolders[$i]); |
||
| 95 | } |
||
| 96 | } |
||
| 97 | // --- COPY blank.png FILES --------------- |
||
| 98 | if (count($configurator->copyBlankFiles) > 0) { |
||
| 99 | $file = __DIR__ . '/../assets/images/blank.png'; |
||
| 100 | foreach (array_keys($configurator->copyBlankFiles) as $i) { |
||
| 101 | $dest = $configurator->copyBlankFiles[$i] . '/blank.png'; |
||
| 102 | $utility::copyFile($file, $dest); |
||
| 103 | } |
||
| 104 | } |
||
| 105 | |||
| 106 | // --- COPY test folder files --------------- |
||
| 107 | if (count($configurator->copyTestFolders) > 0) { |
||
| 108 | // $file = __DIR__ . '/../testdata/images/'; |
||
| 109 | foreach (array_keys($configurator->copyTestFolders) as $i) { |
||
| 110 | $src = $configurator->copyTestFolders[$i][0]; |
||
| 111 | $dest = $configurator->copyTestFolders[$i][1]; |
||
| 112 | $utility::xcopy($src, $dest); |
||
| 113 | } |
||
| 114 | } |
||
| 115 | |||
| 116 | //delete .html entries from the tpl table |
||
| 117 | $sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('tplfile') . " WHERE `tpl_module` = '" . $module->getVar('dirname', 'n') . "' AND `tpl_file` LIKE '%.html%'"; |
||
| 118 | $GLOBALS['xoopsDB']->queryF($sql); |
||
| 119 | |||
| 120 | return true; |
||
| 121 | } |
||
| 122 |