Conditions | 5 |
Paths | 16 |
Total Lines | 54 |
Code Lines | 44 |
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 declare(strict_types=1); |
||
67 | function xoops_module_install_xhttperror(\XoopsObject $module) |
||
68 | { |
||
69 | xoops_loadLanguage('modinfo', $module->getVar('dirname')); |
||
70 | require_once XOOPS_ROOT_PATH . '/modules/' . $module->getVar('dirname') . '/include/functions.php'; |
||
71 | |||
72 | $ret = true; |
||
73 | $msg = ''; |
||
74 | // load classes |
||
75 | $helper = Helper::getInstance(); |
||
76 | $errorHandler = $helper->getHandler('Error'); |
||
77 | $error = $errorHandler->create(); |
||
78 | $error->setVar('error_title', 'Error 404 - Document Not Found'); |
||
79 | $error->setVar('error_statuscode', '404'); |
||
80 | $error->setVar( |
||
81 | 'error_text', |
||
82 | '<p style="font-weight: bold; text-align: center">The page you requested could not be found.</p><p>You may not be able to find the requested page because:</p><ul><li>The page no longer exists.</li><li>The address/page name was mis-typed.</li><li>You followed an incorrect, or out of date link on another site.</li><li>You followed an out of date search engine listing, or personal bookmark/favourite.</li></ul><p>Please try visiting the <a href="/">home page</a>, or use the search function below to find the page you were after.</p>' |
||
83 | ); |
||
84 | $error->setVar('error_showme', true); |
||
85 | $error->setVar('error_redirect', false); |
||
86 | $error->setVar('error_redirect_time', 3); |
||
87 | $error->setVar('error_redirect_uri', XOOPS_URL); |
||
88 | if (!$errorHandler->insert($error)) { |
||
89 | $msg = $msg . $error->getHtmlErrors(); |
||
90 | } |
||
91 | unset($error); |
||
92 | $error = $errorHandler->create(); |
||
93 | $error->setVar('error_title', 'Error 500 - Server error'); |
||
94 | $error->setVar('error_statuscode', '500'); |
||
95 | $error->setVar('error_text', '<p style="font-weight: bold; text-align: center;">The server encountered an internal error and was unable to complete your request.</p>'); |
||
96 | $error->setVar('error_showme', true); |
||
97 | $error->setVar('error_redirect', false); |
||
98 | $error->setVar('error_redirect_time', 3); |
||
99 | $error->setVar('error_redirect_uri', XOOPS_URL); |
||
100 | if (!$errorHandler->insert($error)) { |
||
101 | $msg = $msg . $error->getHtmlErrors(); |
||
102 | } |
||
103 | unset($error); |
||
104 | $error = $errorHandler->create(); |
||
105 | $error->setVar('error_title', 'Error 403 - Forbidden'); |
||
106 | $error->setVar('error_statuscode', '403'); |
||
107 | $error->setVar('error_text', '<p style="font-weight: bold; text-align: center;">You do not have permission to access the requested directory/file.</p>'); |
||
108 | $error->setVar('error_showme', true); |
||
109 | $error->setVar('error_redirect', false); |
||
110 | $error->setVar('error_redirect_time', 3); |
||
111 | $error->setVar('error_redirect_uri', XOOPS_URL); |
||
112 | if (!$errorHandler->insert($error)) { |
||
113 | $msg = $msg . $error->getHtmlErrors(); |
||
114 | } |
||
115 | unset($error); |
||
116 | if (empty($msg)) { |
||
117 | return $ret; |
||
118 | } |
||
119 | |||
120 | return $msg; |
||
121 | } |
||
122 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.