Conditions | 11 |
Paths | 256 |
Total Lines | 76 |
Lines | 13 |
Ratio | 17.11 % |
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 |
||
54 | function xoops_module_install_apcal(XoopsModule $xoopsModule) |
||
55 | { |
||
56 | require_once __DIR__ . '/../../../mainfile.php'; |
||
57 | require_once __DIR__ . '/../include/config.php'; |
||
58 | |||
59 | if (!isset($moduleDirName)) { |
||
|
|||
60 | $moduleDirName = basename(dirname(__DIR__)); |
||
61 | } |
||
62 | |||
63 | if (false !== ($moduleHelper = Xmf\Module\Helper::getHelper($moduleDirName))) { |
||
64 | } else { |
||
65 | $moduleHelper = Xmf\Module\Helper::getHelper('system'); |
||
66 | } |
||
67 | |||
68 | // Load language files |
||
69 | $moduleHelper->loadLanguage('admin'); |
||
70 | $moduleHelper->loadLanguage('modinfo'); |
||
71 | |||
72 | $configurator = new ModuleConfigurator(); |
||
73 | $classUtility = ucfirst($moduleDirName) . 'Utility'; |
||
74 | if (!class_exists($classUtility)) { |
||
75 | xoops_load('utility', $moduleDirName); |
||
76 | } |
||
77 | //------------------------------------ |
||
78 | $ret = true; |
||
79 | $errors = transferTable('event'); |
||
80 | if ($errors !== '') { |
||
81 | $ret = false; |
||
82 | } |
||
83 | //echo $errors ? 'Error inserting these ids in event:<br>'.$errors : 'Insertion succesful!<br>'; |
||
84 | $errors = transferTable('cat'); |
||
85 | if ($errors !== '') { |
||
86 | $ret = false; |
||
87 | } |
||
88 | //echo $errors ? 'Error inserting these ids in cat:<br>'.$errors : 'Insertion succesful!<br>'; |
||
89 | $errors = transferTable('plugins'); |
||
90 | if ($errors !== '') { |
||
91 | $ret = false; |
||
92 | } |
||
93 | //echo $errors ? 'Error inserting these ids in plugins:<br>'.$errors : 'Insertion succesful!<br>'; |
||
94 | setDefaultPerm(); |
||
95 | makeShortEventAftertransfer(); |
||
96 | makeShortCatAftertransfer(); |
||
97 | |||
98 | $GLOBALS['xoopsDB']->queryF("UPDATE {$GLOBALS['xoopsDB']->prefix('apcal_event')} SET start_date=NULL,end_date=NULL"); |
||
99 | $GLOBALS['xoopsDB']->queryF("UPDATE {$GLOBALS['xoopsDB']->prefix('apcal_event')} t, (SELECT id, shortsummary FROM {$GLOBALS['xoopsDB']->prefix('apcal_event')} x WHERE x.rrule_pid>0 GROUP BY x.shortsummary ORDER BY start) AS e SET t.rrule_pid=e.id WHERE t.shortsummary=e.shortsummary;"); |
||
100 | |||
101 | // if (!is_dir(XOOPS_UPLOAD_PATH . '/apcal/')) { |
||
102 | // mkdir(XOOPS_UPLOAD_PATH . '/apcal/', 0755); |
||
103 | // } |
||
104 | // if (!is_dir(XOOPS_UPLOAD_PATH . '/apcal/thumbs/')) { |
||
105 | // mkdir(XOOPS_UPLOAD_PATH . '/apcal/thumbs/', 0755); |
||
106 | // } |
||
107 | |||
108 | // --- CREATE FOLDERS --------------- |
||
109 | View Code Duplication | if (count($configurator->uploadFolders) > 0) { |
|
110 | // foreach (array_keys($GLOBALS['uploadFolders']) as $i) { |
||
111 | foreach (array_keys($configurator->uploadFolders) as $i) { |
||
112 | $classUtility::createFolder($configurator->uploadFolders[$i]); |
||
113 | } |
||
114 | } |
||
115 | |||
116 | // --- COPY blank.png FILES --------------- |
||
117 | View Code Duplication | if (count($configurator->blankFiles) > 0) { |
|
118 | $file = __DIR__ . '/../assets/images/blank.png'; |
||
119 | foreach (array_keys($configurator->blankFiles) as $i) { |
||
120 | $dest = $configurator->blankFiles[$i] . '/blank.png'; |
||
121 | $classUtility::copyFile($file, $dest); |
||
122 | } |
||
123 | } |
||
124 | //delete .html entries from the tpl table |
||
125 | $sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('tplfile') . " WHERE `tpl_module` = '" . $xoopsModule->getVar('dirname', 'n') . "' AND `tpl_file` LIKE '%.html%'"; |
||
126 | $GLOBALS['xoopsDB']->queryF($sql); |
||
127 | |||
128 | return $ret; |
||
129 | } |
||
130 | |||
299 |
This check marks calls to
isset(...)
orempty(...)
that are found before the variable itself is defined. These will always have the same result.This is likely the result of code being shifted around. Consider removing these calls.