| Conditions | 11 |
| Paths | 11 |
| Total Lines | 25 |
| Code Lines | 23 |
| 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 |
||
| 60 | public function recodeValue($x) |
||
| 61 | { |
||
| 62 | switch ($x) { |
||
| 63 | case 0: |
||
| 64 | return 1; |
||
| 65 | case 1: |
||
| 66 | return 0; |
||
| 67 | case 2: |
||
| 68 | return 5; |
||
| 69 | case 3: |
||
| 70 | return 7; |
||
| 71 | case 4: |
||
| 72 | return 9; |
||
| 73 | case 5: |
||
| 74 | return 13; |
||
| 75 | case 6: |
||
| 76 | return 15; |
||
| 77 | case 7: |
||
| 78 | return 17; |
||
| 79 | case 8: |
||
| 80 | return 19; |
||
| 81 | case 9: |
||
| 82 | return 21; |
||
| 83 | default: |
||
| 84 | return -1; |
||
| 85 | } |
||
| 88 |