| Conditions | 4 |
| Paths | 4 |
| Total Lines | 60 |
| Code Lines | 17 |
| 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 |
||
| 43 | function xoops_module_uninstall_chess(\XoopsModule $module) |
||
| 44 | { |
||
| 45 | require __DIR__ . '/common.php'; |
||
| 46 | |||
| 47 | $moduleDirName = basename(dirname(__DIR__)); |
||
| 48 | |||
| 49 | $moduleDirNameUpper = mb_strtoupper($moduleDirName); |
||
| 50 | |||
| 51 | $helper = Chess\Helper::getInstance(); |
||
| 52 | |||
| 53 | $utility = new Chess\Utility(); |
||
| 54 | // $configurator = new Chess\Common\Configurator(); |
||
| 55 | |||
| 56 | // Load language files |
||
| 57 | |||
| 58 | $helper->loadLanguage('admin'); |
||
| 59 | |||
| 60 | $helper->loadLanguage('common'); |
||
| 61 | |||
| 62 | $success = true; |
||
| 63 | |||
| 64 | //------------------------------------------------------------------ |
||
| 65 | |||
| 66 | // Remove uploads folder (and all subfolders) if they exist |
||
| 67 | |||
| 68 | //------------------------------------------------------------------ |
||
| 69 | |||
| 70 | $old_directories = [$GLOBALS['xoops']->path("uploads/{$moduleDirName}")]; |
||
| 71 | |||
| 72 | foreach ($old_directories as $old_dir) { |
||
| 73 | $dirInfo = new SplFileInfo($old_dir); |
||
| 74 | |||
| 75 | if ($dirInfo->isDir()) { |
||
| 76 | // The directory exists so delete it |
||
| 77 | |||
| 78 | if (false === $utility::rrmdir($old_dir)) { |
||
| 79 | $module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_DEL_PATH'), $old_dir)); |
||
| 80 | |||
| 81 | $success = false; |
||
| 82 | } |
||
| 83 | } |
||
| 84 | |||
| 85 | unset($dirInfo); |
||
| 86 | } |
||
| 87 | |||
| 88 | /* |
||
| 89 | //------------ START ---------------- |
||
| 90 | //------------------------------------------------------------------ |
||
| 91 | // Remove xsitemap.xml from XOOPS root folder if it exists |
||
| 92 | //------------------------------------------------------------------ |
||
| 93 | $xmlfile = $GLOBALS['xoops']->path('xsitemap.xml'); |
||
| 94 | if (is_file($xmlfile)) { |
||
| 95 | if (false === ($delOk = unlink($xmlfile))) { |
||
| 96 | $module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_REMOVE'), $xmlfile)); |
||
| 97 | } |
||
| 98 | } |
||
| 99 | // return $success && $delOk; // use this if you're using this routine |
||
| 100 | */ |
||
| 101 | |||
| 102 | return $success; |
||
| 103 | //------------ END ---------------- |
||
| 105 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.