Conditions | 9 |
Paths | 8 |
Total Lines | 94 |
Code Lines | 52 |
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 namespace XoopsModules\Smartobject; |
||
90 | public function render() |
||
91 | { |
||
92 | /** |
||
93 | * @todo move the output to a template |
||
94 | * @todo make the output XHTML compliant |
||
95 | */ |
||
96 | |||
97 | $myts = \MyTextSanitizer::getInstance(); |
||
98 | |||
99 | global $xoopsModule; |
||
100 | |||
101 | Smartobject\Utility::getXoopsCpHeader(); |
||
102 | |||
103 | /** @var XoopsModuleHandler $moduleHandler */ |
||
104 | $moduleHandler = xoops_getHandler('module'); |
||
105 | $versioninfo = $moduleHandler->get($xoopsModule->getVar('mid')); |
||
106 | |||
107 | //Smartobject\Utility::getAdminMenu(-1, $this->_aboutTitle . " " . $versioninfo->getInfo('name')); |
||
108 | |||
109 | require_once XOOPS_ROOT_PATH . '/class/template.php'; |
||
110 | |||
111 | // --- |
||
112 | // 2012-01-01 PHP 5.3: Assigning the return value of new by reference is now deprecated. |
||
113 | // $this->_tpl = new \XoopsTpl(); |
||
114 | $this->_tpl = new \XoopsTpl(); |
||
115 | // --- |
||
116 | |||
117 | $this->_tpl->assign('module_url', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/'); |
||
118 | $this->_tpl->assign('module_image', $versioninfo->getInfo('image')); |
||
119 | $this->_tpl->assign('module_name', $versioninfo->getInfo('name')); |
||
120 | $this->_tpl->assign('module_version', $versioninfo->getInfo('version')); |
||
121 | $this->_tpl->assign('module_status_version', $versioninfo->getInfo('status_version')); |
||
122 | |||
123 | // Left headings... |
||
124 | if ('' !== $versioninfo->getInfo('author_realname')) { |
||
125 | $author_name = $versioninfo->getInfo('author') . ' (' . $versioninfo->getInfo('author_realname') . ')'; |
||
126 | } else { |
||
127 | $author_name = $versioninfo->getInfo('author'); |
||
128 | } |
||
129 | $this->_tpl->assign('module_author_name', $author_name); |
||
130 | |||
131 | $this->_tpl->assign('module_license', $versioninfo->getInfo('license')); |
||
132 | |||
133 | $this->_tpl->assign('module_credits', $versioninfo->getInfo('credits')); |
||
134 | |||
135 | // Developers Information |
||
136 | $this->_tpl->assign('module_developer_lead', $versioninfo->getInfo('developer_lead')); |
||
137 | $this->_tpl->assign('module_developer_contributor', $versioninfo->getInfo('developer_contributor')); |
||
138 | $this->_tpl->assign('module_developer_website_url', $versioninfo->getInfo('developer_website_url')); |
||
139 | $this->_tpl->assign('module_developer_website_name', $versioninfo->getInfo('developer_website_name')); |
||
140 | $this->_tpl->assign('module_developer_email', $versioninfo->getInfo('developer_email')); |
||
141 | |||
142 | $people = $versioninfo->getInfo('people'); |
||
143 | if ($people) { |
||
144 | $this->_tpl->assign('module_people_developers', isset($people['developers']) ? array_map([$this, 'sanitize'], $people['developers']) : false); |
||
145 | $this->_tpl->assign('module_people_testers', isset($people['testers']) ? array_map([$this, 'sanitize'], $people['testers']) : false); |
||
146 | $this->_tpl->assign('module_people_translators', isset($people['translators']) ? array_map([$this, 'sanitize'], $people['translators']) : false); |
||
147 | $this->_tpl->assign('module_people_documenters', isset($people['documenters']) ? array_map([$this, 'sanitize'], $people['documenters']) : false); |
||
148 | $this->_tpl->assign('module_people_other', isset($people['other']) ? array_map([$this, 'sanitize'], $people['other']) : false); |
||
149 | } |
||
150 | //$this->_tpl->assign('module_developers', $versioninfo->getInfo('developer_email')); |
||
151 | |||
152 | // Module Development information |
||
153 | $this->_tpl->assign('module_date', $versioninfo->getInfo('date')); |
||
154 | $this->_tpl->assign('module_status', $versioninfo->getInfo('status')); |
||
155 | $this->_tpl->assign('module_demo_site_url', $versioninfo->getInfo('demo_site_url')); |
||
156 | $this->_tpl->assign('module_demo_site_name', $versioninfo->getInfo('demo_site_name')); |
||
157 | $this->_tpl->assign('module_support_site_url', $versioninfo->getInfo('support_site_url')); |
||
158 | $this->_tpl->assign('module_support_site_name', $versioninfo->getInfo('support_site_name')); |
||
159 | $this->_tpl->assign('module_submit_bug', $versioninfo->getInfo('submit_bug')); |
||
160 | $this->_tpl->assign('module_submit_feature', $versioninfo->getInfo('submit_feature')); |
||
161 | |||
162 | // Warning |
||
163 | $this->_tpl->assign('module_warning', $this->sanitize($versioninfo->getInfo('warning'))); |
||
164 | |||
165 | // Author's note |
||
166 | $this->_tpl->assign('module_author_word', $versioninfo->getInfo('author_word')); |
||
167 | |||
168 | // For changelog thanks to 3Dev |
||
169 | global $xoopsModule; |
||
170 | $filename = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/changelog.txt'; |
||
171 | if (is_file($filename)) { |
||
172 | $filesize = filesize($filename); |
||
173 | $handle = fopen($filename, 'r'); |
||
174 | $this->_tpl->assign('module_version_history', $myts->displayTarea(fread($handle, $filesize), true)); |
||
175 | fclose($handle); |
||
176 | } |
||
177 | |||
178 | $this->_tpl->display('db:smartobject_about.tpl'); |
||
179 | |||
180 | Smartobject\Utility::getModFooter(); |
||
181 | |||
182 | xoops_cp_footer(); |
||
183 | } |
||
184 | } |
||
185 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.