Conditions | 1 |
Paths | 1 |
Total Lines | 60 |
Code Lines | 34 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
172 | public function localizedFormatProvider() { |
||
173 | |||
174 | #0 |
||
175 | $provider[] = array( |
||
176 | '1/2000/12/12/1/1/20/200', |
||
177 | 'en', |
||
178 | '01:01:20, 12 December 2000' |
||
179 | ); |
||
180 | |||
181 | #1 |
||
182 | $provider[] = array( |
||
183 | '1/2000/12/12/1/1/20/200', |
||
184 | 'ja', |
||
185 | '2000年12月12日 (火) 01:01:20' |
||
186 | ); |
||
187 | |||
188 | #2 |
||
189 | $provider[] = array( |
||
190 | '1/2000/12/12/1/1/20/200', |
||
191 | 'es', |
||
192 | '01:01:20 12 dic 2000' |
||
193 | ); |
||
194 | |||
195 | #3 |
||
196 | $provider['on daynumber 1'] = array( |
||
197 | '1/2016/05/02/1/1/20/200', |
||
198 | 'ja', |
||
199 | '2016年5月2日 (月) 01:01:20' |
||
200 | ); |
||
201 | |||
202 | #4 |
||
203 | $provider['on daynumber 7'] = array( |
||
204 | '1/2016/05/08/1/1/20/200', |
||
205 | 'ja', |
||
206 | '2016年5月8日 (日) 01:01:20' |
||
207 | ); |
||
208 | |||
209 | #5 |
||
210 | $provider['midnight-ja'] = array( |
||
211 | '1/2016/05/08/00/00/00/00', |
||
212 | 'ja', |
||
213 | '2016年5月8日 (日) 00:00:00' |
||
214 | ); |
||
215 | |||
216 | #6 |
||
217 | $provider['midnight-en'] = array( |
||
218 | '1/2016/05/08/0/0/0/0', |
||
219 | 'en', |
||
220 | '00:00:00, 8 May 2016' |
||
221 | ); |
||
222 | |||
223 | #6 |
||
224 | $provider['after-midnight'] = array( |
||
225 | '1/2016/05/08/0/0/01/0', |
||
226 | 'en', |
||
227 | '00:00:01, 8 May 2016' |
||
228 | ); |
||
229 | |||
230 | return $provider; |
||
231 | } |
||
232 | } |
||
233 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.