Conditions | 8 |
Paths | 8 |
Total Lines | 62 |
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 |
||
123 | public function GetDebugInfo(&$view) { |
||
124 | global $i_db_query_times; |
||
125 | |||
126 | // Record run end time |
||
127 | $this->fTimeEnd = microtime(true); |
||
128 | // Generate info str, time used |
||
129 | $s = ''; |
||
130 | $time_used = $this->fTimeEnd - $this->fTimeStart; |
||
131 | $time_used = round($time_used, 4); |
||
132 | $s .= "<p>Processed in $time_used seconds"; |
||
133 | // Db query times |
||
134 | if (isset($i_db_query_times)) |
||
135 | $s .= ", $i_db_query_times db queries"; |
||
136 | |||
137 | // Cache, Notice: this msg is delayed if cache on. |
||
138 | if (true == $view->bCacheOn) { |
||
139 | $key = $view->CacheKey(); |
||
140 | $s .= ', cache lifetime: ' . $view->CacheLifetime($key); |
||
141 | |||
142 | // Refresh link, avoid robot claw |
||
143 | $s .= ' <a href="javascript:'; |
||
144 | $s_t = SetUrlParam(GetSelfUrl(true), 'cache', 0); |
||
145 | // Avoid robot claw, break it to several part |
||
146 | $ar = preg_split('/(\:|\/|\.|\?|\&)/', $s_t, 0, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); |
||
147 | $i = count($ar); // Impossible =0 |
||
148 | for ($j = 0; $j < $i; $j++) |
||
149 | // fcr = footer cache refresh |
||
150 | $s .= "fcr$j='{$ar[$i - $j - 1]}';"; |
||
151 | $s .= 'fcr='; |
||
152 | for ($j = 0; $j < $i; $j++) |
||
153 | $s .= 'fcr' . ($i - $j - 1) . '+'; |
||
154 | $s .= '\'\';location.href=fcr;'; |
||
155 | $s .= '">R</a>'; |
||
156 | } |
||
157 | |||
158 | $s .= ".</p>\n"; |
||
159 | |||
160 | // Add Cache log of get operate |
||
161 | if (!empty(Cache::$aLogGet)) { |
||
162 | $s = substr($s, 0, strlen($s) - 6); |
||
163 | $s .= ', cache <span style="cursor: pointer;" |
||
164 | onclick="javascript: |
||
165 | var obj=getElementById(\'fwlib_debuginfo_cache_logget\'); |
||
166 | if (\'none\'==obj.style.display || \'\'==obj.style.display) |
||
167 | {obj.style.display=\'block\';} |
||
168 | else |
||
169 | {obj.style.display=\'none\';};"> |
||
170 | logget</span>.</p>' . "\n"; |
||
171 | $s .= '<ul id="fwlib_debuginfo_cache_logget" |
||
172 | style="display: none;">' . "\n"; |
||
173 | foreach (Cache::$aLogGet as $v) { |
||
174 | $v['key'] = filter_var($v['key'], FILTER_SANITIZE_STRING ); |
||
175 | $v['success'] = filter_var($v['success'], FILTER_SANITIZE_STRING ); |
||
176 | $s .= ' <li style="text-align: left">' |
||
177 | . (($v['success']) ? '√' : '×') . ': ' |
||
178 | . $v['key'] . '</li>' . "\n"; |
||
179 | } |
||
180 | $s .= '</ul>' . "\n"; |
||
181 | } |
||
182 | |||
183 | return $s; |
||
184 | } // end of func GetDebugInfo |
||
185 | |||
242 |
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.