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 |
||
14 | function getBulan($bln) |
||
15 | { |
||
16 | switch ($bln) { |
||
17 | |||
18 | case 1: |
||
19 | |||
20 | return '01'; |
||
21 | |||
22 | break; |
||
|
|||
23 | |||
24 | case 2: |
||
25 | |||
26 | return '02'; |
||
27 | |||
28 | break; |
||
29 | |||
30 | case 3: |
||
31 | |||
32 | return '03'; |
||
33 | |||
34 | break; |
||
35 | |||
36 | case 4: |
||
37 | |||
38 | return '04'; |
||
39 | |||
40 | break; |
||
41 | |||
42 | case 5: |
||
43 | |||
44 | return '05'; |
||
45 | |||
46 | break; |
||
47 | |||
48 | case 6: |
||
49 | |||
50 | return '06'; |
||
51 | |||
52 | break; |
||
53 | |||
54 | case 7: |
||
55 | |||
56 | return '07'; |
||
57 | |||
58 | break; |
||
59 | |||
60 | case 8: |
||
61 | |||
62 | return '08'; |
||
63 | |||
64 | break; |
||
65 | |||
66 | case 9: |
||
67 | |||
68 | return '09'; |
||
69 | |||
70 | break; |
||
71 | |||
72 | case 10: |
||
73 | |||
74 | return '10'; |
||
75 | |||
76 | break; |
||
77 | |||
78 | case 11: |
||
79 | |||
80 | return '11'; |
||
81 | |||
82 | break; |
||
83 | |||
84 | case 12: |
||
85 | |||
86 | return '12'; |
||
87 | |||
88 | break; |
||
89 | |||
185 |
The
break
statement is not necessary if it is preceded for example by areturn
statement:If you would like to keep this construct to be consistent with other
case
statements, you can safely mark this issue as a false-positive.