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