| Conditions | 13 |
| Paths | 13 |
| Total Lines | 75 |
| Code Lines | 37 |
| 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 |
||
| 4 | function getUsia($bln) |
||
| 5 | { |
||
| 6 | switch ($bln) { |
||
| 7 | |||
| 8 | case 1: |
||
| 9 | |||
| 10 | return '12'; |
||
| 11 | |||
| 12 | break; |
||
|
|
|||
| 13 | |||
| 14 | case 2: |
||
| 15 | |||
| 16 | return '11'; |
||
| 17 | |||
| 18 | break; |
||
| 19 | |||
| 20 | case 3: |
||
| 21 | |||
| 22 | return '10'; |
||
| 23 | |||
| 24 | break; |
||
| 25 | |||
| 26 | case 4: |
||
| 27 | |||
| 28 | return '9'; |
||
| 29 | |||
| 30 | break; |
||
| 31 | |||
| 32 | case 5: |
||
| 33 | |||
| 34 | return '8'; |
||
| 35 | |||
| 36 | break; |
||
| 37 | |||
| 38 | case 6: |
||
| 39 | |||
| 40 | return '7'; |
||
| 41 | |||
| 42 | break; |
||
| 43 | |||
| 44 | case 7: |
||
| 45 | |||
| 46 | return '6'; |
||
| 47 | |||
| 48 | break; |
||
| 49 | |||
| 50 | case 8: |
||
| 51 | |||
| 52 | return '5'; |
||
| 53 | |||
| 54 | break; |
||
| 55 | |||
| 56 | case 9: |
||
| 57 | |||
| 58 | return '4'; |
||
| 59 | |||
| 60 | break; |
||
| 61 | |||
| 62 | case 10: |
||
| 63 | |||
| 64 | return '3'; |
||
| 65 | |||
| 66 | break; |
||
| 67 | |||
| 68 | case 11: |
||
| 69 | |||
| 70 | return '2'; |
||
| 71 | |||
| 72 | break; |
||
| 73 | |||
| 74 | case 12: |
||
| 75 | |||
| 76 | return '1'; |
||
| 77 | |||
| 78 | break; |
||
| 79 | |||
| 85 |
The
breakstatement is not necessary if it is preceded for example by areturnstatement:If you would like to keep this construct to be consistent with other
casestatements, you can safely mark this issue as a false-positive.