| Conditions | 4 |
| Paths | 6 |
| Total Lines | 119 |
| Code Lines | 99 |
| 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 |
||
| 56 | public function render() |
||
| 57 | { |
||
| 58 | static $included = false; |
||
| 59 | |||
| 60 | $ele_name = $this->getName(); |
||
| 61 | $ele_value = $this->getValue(true); |
||
| 62 | // if (is_string($ele_value)) { |
||
| 63 | if (!\is_numeric($ele_value)) { |
||
| 64 | $display_value = $ele_value; |
||
| 65 | $ele_value = \time(); |
||
| 66 | } else { |
||
| 67 | // $display_value = ''; |
||
| 68 | // $display_value = formatTimestamp($ele_value, 'm'); |
||
| 69 | $display_value = \ucfirst(\date(_MEDIUMDATESTRING, $ele_value)); |
||
| 70 | } |
||
| 71 | |||
| 72 | if (\is_object($GLOBALS['xoTheme'])) { |
||
| 73 | $moduleHandler = \xoops_getHandler('module'); |
||
| 74 | $sys_module = $moduleHandler->getByDirname('system'); |
||
| 75 | $configHandler = \xoops_getHandler('config'); |
||
| 76 | $moduleConfig = $configHandler->getConfigsByCat(0, $sys_module->getVar('mid')); |
||
| 77 | $jq_theme_dir = $moduleConfig['jquery_theme']; |
||
| 78 | |||
| 79 | $GLOBALS['xoTheme']->addStylesheet($GLOBALS['xoops']->url("modules/system/css/ui/{$jq_theme_dir}/ui.all.css")); |
||
| 80 | $GLOBALS['xoTheme']->addScript('browse.php?Frameworks/jquery/jquery.js'); |
||
| 81 | $GLOBALS['xoTheme']->addScript('browse.php?Frameworks/jquery/plugins/jquery.ui.js'); |
||
| 82 | $GLOBALS['xoTheme']->addScript('browse.php?modules/xoopspoll/assets/js/jquery-ui-timepicker-addon.js'); |
||
| 83 | $GLOBALS['xoTheme']->addScript('browse.php?modules/xoopspoll/assets/js/jquery-ui-sliderAccess.js'); |
||
| 84 | $GLOBALS['xoTheme']->addStylesheet($GLOBALS['xoops']->url('modules/xoopspoll/assets/css/datetimepicker.css')); |
||
| 85 | |||
| 86 | if (!$included) { |
||
| 87 | $included = true; |
||
| 88 | \xoops_loadLanguage('admin', 'xoopspoll'); |
||
| 89 | // setup regional date variables |
||
| 90 | $reg_values = "closeText: '" |
||
| 91 | . \_AM_XOOPSPOLL_DTP_CLOSETEXT |
||
| 92 | . "'," |
||
| 93 | . "prevText: '" |
||
| 94 | . \_AM_XOOPSPOLL_DTP_PREVTEXT |
||
| 95 | . "'," |
||
| 96 | . "nextText: '" |
||
| 97 | . \_AM_XOOPSPOLL_DTP_NEXTTEXT |
||
| 98 | . "'," |
||
| 99 | . "currentText: '" |
||
| 100 | . \_AM_XOOPSPOLL_DTP_CURRENTTEXT |
||
| 101 | . "'," |
||
| 102 | . 'monthNames: [' |
||
| 103 | . \_AM_XOOPSPOLL_DTP_MONTHNAMES |
||
| 104 | . '],' |
||
| 105 | . 'monthNamesShort: [' |
||
| 106 | . \_AM_XOOPSPOLL_DTP_MONTHNAMESSHORT |
||
| 107 | . '],' |
||
| 108 | . 'dayNames: [' |
||
| 109 | . \_AM_XOOPSPOLL_DTP_DAYNAMES |
||
| 110 | . '],' |
||
| 111 | . 'dayNamesShort: [' |
||
| 112 | . \_AM_XOOPSPOLL_DTP_DAYNAMESSHORT |
||
| 113 | . '],' |
||
| 114 | . 'dayNamesMin: [' |
||
| 115 | . \_AM_XOOPSPOLL_DTP_DAYNAMESMIN |
||
| 116 | . '],' |
||
| 117 | . "weekHeader: '" |
||
| 118 | . \_AM_XOOPSPOLL_DTP_WEEKHEADER |
||
| 119 | . "'," |
||
| 120 | . "dateFormat: '" |
||
| 121 | . \_AM_XOOPSPOLL_DTP_DATEFORMAT |
||
| 122 | . "'," |
||
| 123 | . "firstDay: '" |
||
| 124 | . \_AM_XOOPSPOLL_DTP_FIRSTDAY |
||
| 125 | . "'," |
||
| 126 | . 'isRTL: ' |
||
| 127 | . \_AM_XOOPSPOLL_DTP_ISRTL |
||
| 128 | . ',' |
||
| 129 | . 'showMonthAfterYear: ' |
||
| 130 | . \_AM_XOOPSPOLL_DTP_SHOWMONTHAFTERYEAR |
||
| 131 | . ',' |
||
| 132 | . "yearSuffix: '" |
||
| 133 | . \_AM_XOOPSPOLL_DTP_YEARSUFFIX |
||
| 134 | . "',"; |
||
| 135 | // set regional time variables |
||
| 136 | $reg_values .= "timeOnlyTitle: '" |
||
| 137 | . \_AM_XOOPSPOLL_DTP_TIMEONLYTITLE |
||
| 138 | . "'," |
||
| 139 | . "timeText: '" |
||
| 140 | . \_AM_XOOPSPOLL_DTP_TIMETEXT |
||
| 141 | . "'," |
||
| 142 | . "hourText: '" |
||
| 143 | . \_AM_XOOPSPOLL_DTP_HOURTEXT |
||
| 144 | . "'," |
||
| 145 | . "minuteText: '" |
||
| 146 | . \_AM_XOOPSPOLL_DTP_MINUTETEXT |
||
| 147 | . "'," |
||
| 148 | . "secondText: '" |
||
| 149 | . \_AM_XOOPSPOLL_DTP_SECONDTEXT |
||
| 150 | . "'," |
||
| 151 | . "millisecText: '" |
||
| 152 | . \_AM_XOOPSPOLL_DTP_MILLISECTEXT |
||
| 153 | . "'," |
||
| 154 | . "timeFormat: '" |
||
| 155 | . \_AM_XOOPSPOLL_DTP_TIMEFORMAT |
||
| 156 | . "'," |
||
| 157 | . 'ampm: false,' |
||
| 158 | . 'stepMinute: 5'; |
||
| 159 | |||
| 160 | $GLOBALS['xoTheme']->addScript( |
||
| 161 | '', |
||
| 162 | '', |
||
| 163 | ' |
||
| 164 | $(function() { |
||
| 165 | $( ".datetimepicker" ).datetimepicker({ |
||
| 166 | ' . $reg_values . ' |
||
| 167 | }); |
||
| 168 | }); |
||
| 169 | ' |
||
| 170 | ); |
||
| 171 | } |
||
| 172 | } |
||
| 173 | |||
| 174 | return "<input type='text' name='{$ele_name}' id='{$ele_name}' class='datetimepicker' size='" . $this->getSize() . "' maxlength='" . $this->getMaxlength() . "' value='{$display_value}'" . $this->getExtra() . '>'; |
||
| 175 | } |
||
| 177 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.