| Conditions | 23 |
| Paths | 23 |
| Total Lines | 50 |
| Code Lines | 47 |
| 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 |
||
| 53 | public function getMatch($number) |
||
| 54 | { |
||
| 55 | if ($number < 10) { |
||
| 56 | return StringUtil::forDigit($number, 10); |
||
| 57 | } |
||
| 58 | switch ($number) { |
||
| 59 | case 10: |
||
| 60 | return 'A'; |
||
| 61 | case 11: |
||
| 62 | return 'B'; |
||
| 63 | case 12: |
||
| 64 | return 'C'; |
||
| 65 | case 13: |
||
| 66 | return 'D'; |
||
| 67 | case 14: |
||
| 68 | return 'E'; |
||
| 69 | case 15: |
||
| 70 | return 'F'; |
||
| 71 | case 16: |
||
| 72 | return 'H'; |
||
| 73 | case 17: |
||
| 74 | return 'J'; |
||
| 75 | case 18: |
||
| 76 | return 'K'; |
||
| 77 | case 19: |
||
| 78 | return 'L'; |
||
| 79 | case 20: |
||
| 80 | return 'M'; |
||
| 81 | case 21: |
||
| 82 | return 'N'; |
||
| 83 | case 22: |
||
| 84 | return 'P'; |
||
| 85 | case 23: |
||
| 86 | return 'R'; |
||
| 87 | case 24: |
||
| 88 | return 'S'; |
||
| 89 | case 25: |
||
| 90 | return 'T'; |
||
| 91 | case 26: |
||
| 92 | return 'U'; |
||
| 93 | case 27: |
||
| 94 | return 'V'; |
||
| 95 | case 28: |
||
| 96 | return 'W'; |
||
| 97 | case 29: |
||
| 98 | return 'X'; |
||
| 99 | case 30: |
||
| 100 | return 'Y'; |
||
| 101 | default: |
||
| 102 | return ' '; |
||
| 103 | } |
||
| 121 |