Conditions | 25 |
Paths | 25 |
Total Lines | 43 |
Code Lines | 35 |
Lines | 0 |
Ratio | 0 % |
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 |
||
7 | static public function canonizeCase($case) { |
||
8 | $case = lower($case); |
||
9 | switch ($case) { |
||
10 | case Cases::IMENIT: |
||
11 | case 'именительный': |
||
12 | case 'именит': |
||
13 | case 'и': |
||
14 | return Cases::IMENIT; |
||
15 | |||
16 | case Cases::RODIT: |
||
17 | case 'родительный': |
||
18 | case 'родит': |
||
19 | case 'р': |
||
20 | return Cases::RODIT; |
||
21 | |||
22 | case Cases::DAT: |
||
23 | case 'дательный': |
||
24 | case 'дат': |
||
25 | case 'д': |
||
26 | return Cases::DAT; |
||
27 | |||
28 | case Cases::VINIT: |
||
29 | case 'винительный': |
||
30 | case 'винит': |
||
31 | case 'в': |
||
32 | return Cases::VINIT; |
||
33 | |||
34 | case Cases::TVORIT: |
||
35 | case 'творительный': |
||
36 | case 'творит': |
||
37 | case 'т': |
||
38 | return Cases::TVORIT; |
||
39 | |||
40 | case Cases::PREDLOJ: |
||
41 | case 'предложный': |
||
42 | case 'предлож': |
||
43 | case 'п': |
||
44 | return Cases::PREDLOJ; |
||
45 | |||
46 | default: |
||
47 | return parent::canonizeCase($case); |
||
48 | } |
||
49 | } |
||
50 | } |
||
51 |