| Conditions | 9 |
| Paths | 132 |
| Total Lines | 70 |
| Code Lines | 42 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
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 |
||
| 32 | public function getMenuitemsDefault() |
||
| 33 | { |
||
| 34 | |||
| 35 | $moduleDirName = \basename(\dirname(__DIR__)); |
||
| 36 | $pathname = \XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/'; |
||
| 37 | |||
| 38 | require_once $pathname . 'include/common.php'; |
||
| 39 | $helper = \XoopsModules\Wgevents\Helper::getInstance(); |
||
| 40 | //load necessary language files from this module |
||
| 41 | $helper->loadLanguage('modinfo'); |
||
| 42 | |||
| 43 | $items = []; |
||
| 44 | $currdirname = isset($GLOBALS['xoopsModule']) && \is_object($GLOBALS['xoopsModule']) ? $GLOBALS['xoopsModule']->getVar('dirname') : 'system'; |
||
| 45 | if ($currdirname == $moduleDirName) { |
||
| 46 | require_once \XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/include/common.php'; |
||
| 47 | $helper = Helper::getInstance(); |
||
| 48 | $permissionsHandler = $helper->getHandler('Permission'); |
||
| 49 | |||
| 50 | $items = []; |
||
| 51 | $items[] = [ |
||
| 52 | 'name' => \_MI_WGEVENTS_SMNAME1, |
||
| 53 | 'url' => 'index.php', |
||
| 54 | ]; |
||
| 55 | // Sub events |
||
| 56 | $items[] = [ |
||
| 57 | 'name' => \_MI_WGEVENTS_SMNAME2, |
||
| 58 | 'url' => 'event.php', |
||
| 59 | ]; |
||
| 60 | if ($permissionsHandler->getPermEventsSubmit()) { |
||
| 61 | // Sub Submit |
||
| 62 | $items[] = [ |
||
| 63 | 'name' => \_MI_WGEVENTS_SMNAME10, |
||
| 64 | 'url' => 'event.php?op=list&filter=me', |
||
| 65 | ]; |
||
| 66 | } |
||
| 67 | if ($permissionsHandler->getPermEventsSubmit()) { |
||
| 68 | // Sub Submit |
||
| 69 | $items[] = [ |
||
| 70 | 'name' => \_MI_WGEVENTS_SMNAME3, |
||
| 71 | 'url' => 'event.php?op=new', |
||
| 72 | ]; |
||
| 73 | } |
||
| 74 | if ($permissionsHandler->getPermEventsSubmit()) { |
||
| 75 | // Sub Submit |
||
| 76 | $items[] = [ |
||
| 77 | 'name' => \_MI_WGEVENTS_SMNAME8, |
||
| 78 | 'url' => 'textblock.php?op=list', |
||
| 79 | ]; |
||
| 80 | } |
||
| 81 | if ($permissionsHandler->getPermRegistrationsSubmit()) { |
||
| 82 | $items[] = [ |
||
| 83 | 'name' => \_MI_WGEVENTS_SMNAME5, |
||
| 84 | 'url' => 'registration.php?op=listmy', |
||
| 85 | ]; |
||
| 86 | } |
||
| 87 | if ($helper->getConfig('cal_page')) { |
||
| 88 | // calendar |
||
| 89 | $items[] = [ |
||
| 90 | 'name' => \_MI_WGEVENTS_SMNAME6, |
||
| 91 | 'url' => 'calendar.php', |
||
| 92 | ]; |
||
| 93 | } |
||
| 94 | // export |
||
| 95 | $items[] = [ |
||
| 96 | 'name' => \_MI_WGEVENTS_SMNAME11, |
||
| 97 | 'url' => 'export.php?op=list&new=1', |
||
| 98 | ]; |
||
| 99 | } |
||
| 100 | |||
| 101 | return $items; |
||
| 102 | } |
||
| 207 |