Conditions | 8 |
Paths | 8 |
Total Lines | 55 |
Code Lines | 29 |
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 |
||
56 | function xoops_module_install_xfguestbook(\XoopsModule $module) |
||
57 | { |
||
58 | require_once dirname(__DIR__) . '/preloads/autoloader.php'; |
||
59 | |||
60 | $moduleDirName = basename(dirname(__DIR__)); |
||
61 | /** @var Helper $helper */ |
||
62 | $helper = Helper::getInstance(); |
||
63 | |||
64 | // Load language files |
||
65 | $helper->loadLanguage('admin'); |
||
66 | $helper->loadLanguage('modinfo'); |
||
67 | |||
68 | $configurator = new Xfguestbook\Common\Configurator(); |
||
69 | $utility = new Utility(); |
||
70 | |||
71 | // default Permission Settings ---------------------- |
||
72 | global $xoopsModule; |
||
73 | $moduleId = $module->getVar('mid'); |
||
74 | // $moduleId2 = $helper->getModule()->mid(); |
||
75 | /** @var \XoopsGroupPermHandler $grouppermHandler */ |
||
76 | $grouppermHandler = xoops_getHandler('groupperm'); |
||
77 | // access rights ------------------------------------------ |
||
78 | $grouppermHandler->addRight($moduleDirName . '_approve', 1, XOOPS_GROUP_ADMIN, $moduleId); |
||
|
|||
79 | $grouppermHandler->addRight($moduleDirName . '_submit', 1, XOOPS_GROUP_ADMIN, $moduleId); |
||
80 | $grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_ADMIN, $moduleId); |
||
81 | $grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_USERS, $moduleId); |
||
82 | $grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_ANONYMOUS, $moduleId); |
||
83 | |||
84 | // --- CREATE FOLDERS --------------- |
||
85 | if (count($configurator->uploadFolders) > 0) { |
||
86 | // foreach (array_keys($GLOBALS['uploadFolders']) as $i) { |
||
87 | foreach (array_keys($configurator->uploadFolders) as $i) { |
||
88 | $utility::createFolder($configurator->uploadFolders[$i]); |
||
89 | } |
||
90 | } |
||
91 | |||
92 | // --- COPY blank.png FILES --------------- |
||
93 | if (count($configurator->copyBlankFiles) > 0) { |
||
94 | $file = dirname(__DIR__) . '/assets/images/blank.png'; |
||
95 | foreach (array_keys($configurator->copyBlankFiles) as $i) { |
||
96 | $dest = $configurator->copyBlankFiles[$i] . '/blank.png'; |
||
97 | $utility::copyFile($file, $dest); |
||
98 | } |
||
99 | } |
||
100 | |||
101 | // --- COPY test msg image --------------- |
||
102 | if ($configurator->copyTestFolders && is_array($configurator->copyTestFolders)) { |
||
103 | foreach (array_keys($configurator->copyTestFolders) as $i) { |
||
104 | $src = $configurator->copyTestFolders[$i][0]; |
||
105 | $dest = $configurator->copyTestFolders[$i][1]; |
||
106 | $utility::rcopy($src, $dest); |
||
107 | } |
||
108 | } |
||
109 | |||
110 | return true; |
||
111 | } |
||
112 |