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 declare(strict_types=1); |
||
53 | public function render(): string |
||
54 | { |
||
55 | static $included = false; |
||
56 | |||
57 | $ele_name = $this->getName(); |
||
58 | $ele_value = $this->getValue(true); |
||
59 | // if (is_string($ele_value)) { |
||
60 | if (\is_numeric($ele_value)) { |
||
61 | // $display_value = ''; |
||
62 | // $display_value = formatTimestamp($ele_value, 'm'); |
||
63 | $display_value = \ucfirst(\date(_MEDIUMDATESTRING, (int)$ele_value)); |
||
64 | } else { |
||
65 | $display_value = $ele_value; |
||
66 | $ele_value = \time(); |
||
67 | } |
||
68 | |||
69 | if (\is_object($GLOBALS['xoTheme'])) { |
||
70 | $moduleHandler = \xoops_getHandler('module'); |
||
71 | $sys_module = $moduleHandler->getByDirname('system'); |
||
72 | $configHandler = \xoops_getHandler('config'); |
||
73 | $moduleConfig = $configHandler->getConfigsByCat(0, $sys_module->getVar('mid')); |
||
74 | $jq_theme_dir = $moduleConfig['jquery_theme']; |
||
75 | |||
76 | $GLOBALS['xoTheme']->addStylesheet($GLOBALS['xoops']->url("modules/system/css/ui/{$jq_theme_dir}/ui.all.css")); |
||
77 | $GLOBALS['xoTheme']->addScript('browse.php?Frameworks/jquery/jquery.js'); |
||
78 | $GLOBALS['xoTheme']->addScript('browse.php?Frameworks/jquery/plugins/jquery.ui.js'); |
||
79 | $GLOBALS['xoTheme']->addScript('browse.php?modules/xoopspoll/assets/js/jquery-ui-timepicker-addon.js'); |
||
80 | $GLOBALS['xoTheme']->addScript('browse.php?modules/xoopspoll/assets/js/jquery-ui-sliderAccess.js'); |
||
81 | $GLOBALS['xoTheme']->addStylesheet($GLOBALS['xoops']->url('modules/xoopspoll/assets/css/datetimepicker.css')); |
||
82 | |||
83 | if (!$included) { |
||
84 | $included = true; |
||
85 | \xoops_loadLanguage('admin', 'xoopspoll'); |
||
86 | // setup regional date variables |
||
87 | $reg_values = "closeText: '" |
||
88 | . \_AM_XOOPSPOLL_DTP_CLOSETEXT |
||
89 | . "'," |
||
90 | . "prevText: '" |
||
91 | . \_AM_XOOPSPOLL_DTP_PREVTEXT |
||
92 | . "'," |
||
93 | . "nextText: '" |
||
94 | . \_AM_XOOPSPOLL_DTP_NEXTTEXT |
||
95 | . "'," |
||
96 | . "currentText: '" |
||
97 | . \_AM_XOOPSPOLL_DTP_CURRENTTEXT |
||
98 | . "'," |
||
99 | . 'monthNames: [' |
||
100 | . \_AM_XOOPSPOLL_DTP_MONTHNAMES |
||
101 | . '],' |
||
102 | . 'monthNamesShort: [' |
||
103 | . \_AM_XOOPSPOLL_DTP_MONTHNAMESSHORT |
||
104 | . '],' |
||
105 | . 'dayNames: [' |
||
106 | . \_AM_XOOPSPOLL_DTP_DAYNAMES |
||
107 | . '],' |
||
108 | . 'dayNamesShort: [' |
||
109 | . \_AM_XOOPSPOLL_DTP_DAYNAMESSHORT |
||
110 | . '],' |
||
111 | . 'dayNamesMin: [' |
||
112 | . \_AM_XOOPSPOLL_DTP_DAYNAMESMIN |
||
113 | . '],' |
||
114 | . "weekHeader: '" |
||
115 | . \_AM_XOOPSPOLL_DTP_WEEKHEADER |
||
116 | . "'," |
||
117 | . "dateFormat: '" |
||
118 | . \_AM_XOOPSPOLL_DTP_DATEFORMAT |
||
119 | . "'," |
||
120 | . "firstDay: '" |
||
121 | . \_AM_XOOPSPOLL_DTP_FIRSTDAY |
||
122 | . "'," |
||
123 | . 'isRTL: ' |
||
124 | . \_AM_XOOPSPOLL_DTP_ISRTL |
||
125 | . ',' |
||
126 | . 'showMonthAfterYear: ' |
||
127 | . \_AM_XOOPSPOLL_DTP_SHOWMONTHAFTERYEAR |
||
128 | . ',' |
||
129 | . "yearSuffix: '" |
||
130 | . \_AM_XOOPSPOLL_DTP_YEARSUFFIX |
||
131 | . "',"; |
||
132 | // set regional time variables |
||
133 | $reg_values .= "timeOnlyTitle: '" |
||
134 | . \_AM_XOOPSPOLL_DTP_TIMEONLYTITLE |
||
135 | . "'," |
||
136 | . "timeText: '" |
||
137 | . \_AM_XOOPSPOLL_DTP_TIMETEXT |
||
138 | . "'," |
||
139 | . "hourText: '" |
||
140 | . \_AM_XOOPSPOLL_DTP_HOURTEXT |
||
141 | . "'," |
||
142 | . "minuteText: '" |
||
143 | . \_AM_XOOPSPOLL_DTP_MINUTETEXT |
||
144 | . "'," |
||
145 | . "secondText: '" |
||
146 | . \_AM_XOOPSPOLL_DTP_SECONDTEXT |
||
147 | . "'," |
||
148 | . "millisecText: '" |
||
149 | . \_AM_XOOPSPOLL_DTP_MILLISECTEXT |
||
150 | . "'," |
||
151 | . "timeFormat: '" |
||
152 | . \_AM_XOOPSPOLL_DTP_TIMEFORMAT |
||
153 | . "'," |
||
154 | . 'ampm: false,' |
||
155 | . 'stepMinute: 5'; |
||
156 | |||
157 | $GLOBALS['xoTheme']->addScript( |
||
158 | '', |
||
159 | '', |
||
160 | ' |
||
161 | $(function() { |
||
162 | $( ".datetimepicker" ).datetimepicker({ |
||
163 | ' . $reg_values . ' |
||
164 | }); |
||
165 | }); |
||
166 | ' |
||
167 | ); |
||
168 | } |
||
169 | } |
||
170 | |||
171 | return "<input type='text' name='{$ele_name}' id='{$ele_name}' class='datetimepicker' size='" . $this->getSize() . "' maxlength='" . $this->getMaxlength() . "' value='{$display_value}'" . $this->getExtra() . '>'; |
||
172 | } |
||
174 |
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.