Conditions | 1 |
Paths | 1 |
Total Lines | 154 |
Code Lines | 107 |
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 |
||
243 | public function timeInputProvider() { |
||
244 | |||
245 | #0 |
||
246 | $provider[] = array( |
||
247 | '2000', |
||
248 | TimeValueFormatter::VALUE, |
||
249 | '', |
||
250 | null, |
||
251 | '', |
||
252 | '2000' |
||
253 | ); |
||
254 | |||
255 | #1 |
||
256 | $provider[] = array( |
||
257 | '2000', |
||
258 | TimeValueFormatter::VALUE, |
||
259 | 'ISO', |
||
260 | null, |
||
261 | '', |
||
262 | '2000' |
||
263 | ); |
||
264 | |||
265 | #2 |
||
266 | $provider[] = array( |
||
267 | '2000', |
||
268 | TimeValueFormatter::WIKI_SHORT, |
||
269 | 'ISO', |
||
270 | null, |
||
271 | '', |
||
272 | '2000' |
||
273 | ); |
||
274 | |||
275 | #3 |
||
276 | $provider[] = array( |
||
277 | '2000', |
||
278 | TimeValueFormatter::HTML_SHORT, |
||
279 | 'ISO', |
||
280 | null, |
||
281 | '', |
||
282 | '2000' |
||
283 | ); |
||
284 | |||
285 | #4 |
||
286 | $provider[] = array( |
||
287 | '2000', |
||
288 | TimeValueFormatter::WIKI_LONG, |
||
289 | 'ISO', |
||
290 | null, |
||
291 | '', |
||
292 | '2000-01-01' |
||
293 | ); |
||
294 | |||
295 | #5 |
||
296 | $provider[] = array( |
||
297 | '2000', |
||
298 | TimeValueFormatter::HTML_LONG, |
||
299 | 'ISO', |
||
300 | null, |
||
301 | '', |
||
302 | '2000-01-01' |
||
303 | ); |
||
304 | |||
305 | #6 |
||
306 | $provider[] = array( |
||
307 | '2000', |
||
308 | TimeValueFormatter::WIKI_LONG, |
||
309 | 'MEDIAWIKI', |
||
310 | null, |
||
311 | '', |
||
312 | '2000' |
||
313 | ); |
||
314 | |||
315 | #7 |
||
316 | $provider[] = array( |
||
317 | '2000', |
||
318 | TimeValueFormatter::HTML_LONG, |
||
319 | 'MEDIAWIKI', |
||
320 | null, |
||
321 | '', |
||
322 | '2000' |
||
323 | ); |
||
324 | |||
325 | #8 |
||
326 | $provider[] = array( |
||
327 | '2000-02', |
||
328 | TimeValueFormatter::VALUE, |
||
329 | '', |
||
330 | null, |
||
331 | '', |
||
332 | '2000-02' |
||
333 | ); |
||
334 | |||
335 | #9 |
||
336 | $provider[] = array( |
||
337 | '2000-02', |
||
338 | TimeValueFormatter::VALUE, |
||
339 | 'ISO', |
||
340 | null, |
||
341 | '', |
||
342 | '2000-02' |
||
343 | ); |
||
344 | |||
345 | #10 |
||
346 | $provider[] = array( |
||
347 | '2000-02', |
||
348 | TimeValueFormatter::WIKI_SHORT, |
||
349 | '', |
||
350 | null, |
||
351 | '', |
||
352 | '2000-02' |
||
353 | ); |
||
354 | |||
355 | #11 |
||
356 | $provider[] = array( |
||
357 | '2000-02', |
||
358 | TimeValueFormatter::HTML_SHORT, |
||
359 | 'ISO', |
||
360 | null, |
||
361 | '', |
||
362 | '2000-02' |
||
363 | ); |
||
364 | |||
365 | #12 |
||
366 | $provider[] = array( |
||
367 | '2000-02', |
||
368 | TimeValueFormatter::WIKI_LONG, |
||
369 | 'ISO', |
||
370 | null, |
||
371 | '', |
||
372 | '2000-02-01' |
||
373 | ); |
||
374 | |||
375 | #13 |
||
376 | $provider[] = array( |
||
377 | '2000-02', |
||
378 | TimeValueFormatter::HTML_LONG, |
||
379 | 'ISO', |
||
380 | null, |
||
381 | '', |
||
382 | '2000-02-01' |
||
383 | ); |
||
384 | |||
385 | #14 |
||
386 | $provider[] = array( |
||
387 | '2000-02', |
||
388 | TimeValueFormatter::HTML_LONG, |
||
389 | 'LOCL', |
||
390 | null, |
||
391 | 'en', |
||
392 | 'February 2000' |
||
393 | ); |
||
394 | |||
395 | return $provider; |
||
396 | } |
||
397 | |||
399 |
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.
Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.