Conditions | 8 |
Paths | 60 |
Total Lines | 118 |
Code Lines | 71 |
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\Mymenus; |
||
182 | public static function editLink($id = null, $pid = null, $mid = null) |
||
183 | { |
||
184 | /** @var \XoopsModules\Mymenus\Helper $helper */ |
||
185 | $helper = \XoopsModules\Mymenus\Helper::getInstance(); |
||
186 | // |
||
187 | // Disable xoops debugger in dialog window |
||
188 | xoops_load('xoopslogger'); |
||
189 | $xoopsLogger = \XoopsLogger::getInstance(); |
||
190 | $xoopsLogger->activated = false; |
||
191 | error_reporting(0); |
||
192 | |||
193 | $pathIcon16 = \Xmf\Module\Admin::iconUrl('', 16); |
||
194 | |||
195 | // $registry = MymenusRegistry::getInstance(); |
||
196 | // $plugin = MymenusPlugin::getInstance(); |
||
197 | |||
198 | $linksObj = $helper->getHandler('Links')->get((int)$id); |
||
199 | |||
200 | if ($linksObj->isNew()) { |
||
201 | $formTitle = _ADD; |
||
202 | if (null !== $pid) { |
||
203 | $linksObj->setVar('pid', (int)$pid); |
||
204 | } |
||
205 | if (null !== $mid) { |
||
206 | $linksObj->setVar('mid', (int)$mid); |
||
207 | } |
||
208 | } else { |
||
209 | $formTitle = _EDIT; |
||
210 | } |
||
211 | $form = new \XoopsThemeForm($formTitle, 'admin_form', $GLOBALS['mymenusAdminPage'], 'post', true); |
||
212 | // links: title |
||
213 | $formtitle = new \XoopsFormText(_AM_MYMENUS_MENU_TITLE, 'title', 50, 255, $linksObj->getVar('title')); |
||
214 | $form->addElement($formtitle, true); |
||
215 | // links: alt_title |
||
216 | $formalttitle = new \XoopsFormText(_AM_MYMENUS_MENU_ALTTITLE, 'alt_title', 50, 255, $linksObj->getVar('alt_title')); |
||
217 | $form->addElement($formalttitle); |
||
218 | // links: mid |
||
219 | $menusCriteria = new \CriteriaCompo(); |
||
220 | $menusCriteria->setSort('title'); |
||
221 | $menusCriteria->setOrder('ASC'); |
||
222 | $menusList = $helper->getHandler('Menus')->getList($menusCriteria); |
||
223 | if (count($menusList) > 1) { |
||
224 | // display menu options (if more than 1 menu available |
||
225 | if (!$linksObj->getVar('mid')) { // initial menu value not set |
||
226 | // $menuValues = array_flip($menusList); |
||
227 | $formmid = new \XoopsFormSelect(_AM_MYMENUS_MENU_MENU, 'mid', $mid);//array_shift($menuValues)); |
||
228 | } else { |
||
229 | $formmid = new \XoopsFormSelect(_AM_MYMENUS_MENU_MENU, 'mid', $linksObj->getVar('mid')); |
||
230 | } |
||
231 | $formmid->addOptionArray($menusList); |
||
232 | } else { |
||
233 | $menuKeys = array_keys($menusList); |
||
234 | $menuTitle = array_shift($menusList); |
||
235 | $formmid = new \XoopsFormElementTray('Menu'); |
||
236 | $formmid->addElement(new \XoopsFormHidden('mid', $menuKeys[0])); |
||
237 | $formmid->addElement(new \XoopsFormLabel('', $menuTitle, 'menuTitle')); |
||
238 | } |
||
239 | $form->addElement($formmid); |
||
240 | // links: link |
||
241 | $formlink = new \XoopsFormText(_AM_MYMENUS_MENU_LINK, 'link', 50, 255, $linksObj->getVar('link')); |
||
242 | $form->addElement($formlink); |
||
243 | // links: image |
||
244 | $formimage = new \XoopsFormText(_AM_MYMENUS_MENU_IMAGE, 'image', 50, 255, $linksObj->getVar('image')); |
||
245 | $form->addElement($formimage); |
||
246 | // |
||
247 | //$form->addElement($formparent); |
||
248 | // links: visible |
||
249 | $statontxt = " <img src='{$pathIcon16}/1.png' alt='" . _YES . "'> " . _YES . ' '; |
||
250 | $statofftxt = " <img src='{$pathIcon16}/0.png' alt='" . _NO . "'> " . _NO . ' '; |
||
251 | $formvis = new \XoopsFormRadioYN(_AM_MYMENUS_MENU_VISIBLE, 'visible', $linksObj->getVar('visible'), $statontxt, $statofftxt); |
||
252 | $form->addElement($formvis); |
||
253 | // links: target |
||
254 | $formtarget = new \XoopsFormSelect(_AM_MYMENUS_MENU_TARGET, 'target', $linksObj->getVar('target')); |
||
255 | $formtarget->addOption('_self', _AM_MYMENUS_MENU_TARG_SELF); |
||
256 | $formtarget->addOption('_blank', _AM_MYMENUS_MENU_TARG_BLANK); |
||
257 | $formtarget->addOption('_parent', _AM_MYMENUS_MENU_TARG_PARENT); |
||
258 | $formtarget->addOption('_top', _AM_MYMENUS_MENU_TARG_TOP); |
||
259 | $form->addElement($formtarget); |
||
260 | // links: groups |
||
261 | $formgroups = new \XoopsFormSelectGroup(_AM_MYMENUS_MENU_GROUPS, 'groups', true, $linksObj->getVar('groups'), 5, true); |
||
262 | $formgroups->setDescription(_AM_MYMENUS_MENU_GROUPS_HELP); |
||
263 | $form->addElement($formgroups); |
||
264 | // @TODO: reintroduce hooks |
||
265 | /* |
||
266 | //links: hooks |
||
267 | $formhooks = new \XoopsFormSelect(_AM_MYMENUS_MENU_ACCESS_FILTER, "hooks", $linksObj->getVar('hooks'), 5, true); |
||
268 | $plugin->triggerEvent('AccessFilter'); |
||
269 | $results = $registry->getEntry('accessFilter'); |
||
270 | if ($results) { |
||
271 | foreach ($results as $result) { |
||
272 | $formhooks->addOption($result['method'], $result['name']); |
||
273 | } |
||
274 | } |
||
275 | $form->addElement($formhooks); |
||
276 | */ |
||
277 | // links: css |
||
278 | $formcss = new \XoopsFormText(_AM_MYMENUS_MENU_CSS, 'css', 50, 255, $linksObj->getVar('css')); |
||
279 | $form->addElement($formcss); |
||
280 | // |
||
281 | $buttonTray = new \XoopsFormElementTray('', ''); |
||
282 | $buttonTray->addElement(new \XoopsFormButton('', 'submit_button', _SUBMIT, 'submit')); |
||
283 | $button = new \XoopsFormButton('', 'reset', _CANCEL, 'button'); |
||
284 | if (null !== $id) { |
||
285 | $button->setExtra("onclick=\"document.location.href='" . $GLOBALS['mymenusAdminPage'] . "?op=list&mid={$mid}'\""); |
||
286 | } else { |
||
287 | $button->setExtra("onclick=\"document.getElementById('addform').style.display = 'none'; return false;\""); |
||
288 | } |
||
289 | $buttonTray->addElement($button); |
||
290 | $form->addElement($buttonTray); |
||
291 | |||
292 | if (null !== $id) { |
||
293 | $form->addElement(new \XoopsFormHidden('op', 'save')); |
||
294 | $form->addElement(new \XoopsFormHidden('id', $id)); |
||
295 | } else { |
||
296 | $form->addElement(new \XoopsFormHidden('op', 'add')); |
||
297 | } |
||
298 | |||
299 | return $form->render(); |
||
300 | } |
||
345 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths