Conditions | 10 |
Paths | 10 |
Total Lines | 24 |
Code Lines | 21 |
Lines | 14 |
Ratio | 58.33 % |
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 |
||
18 | View Code Duplication | function desc() |
|
|
|||
19 | { |
||
20 | global $code; |
||
21 | switch ($code) { |
||
22 | case 400: |
||
23 | return 'Bad Request'; |
||
24 | case 401: |
||
25 | return 'Unauthorized'; |
||
26 | case 403: |
||
27 | return 'Forbidden'; |
||
28 | case 404: |
||
29 | return 'Not Found'; |
||
30 | case 500: |
||
31 | return 'Internal Server Error'; |
||
32 | case 501: |
||
33 | return 'Not Implemented'; |
||
34 | case 502: |
||
35 | return 'Bad Gateway'; |
||
36 | case 503: |
||
37 | return 'Service Unavailable'; |
||
38 | case 504: |
||
39 | return 'Bad Timeout'; |
||
40 | } |
||
41 | } |
||
42 | |||
69 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.