Conditions | 18 |
Paths | 18 |
Total Lines | 37 |
Lines | 0 |
Ratio | 0 % |
Tests | 25 |
CRAP Score | 18.0184 |
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 |
||
13 | 6 | public static function canonizeCase($case) |
|
14 | { |
||
15 | 6 | $case = S::lower($case); |
|
16 | switch ($case) { |
||
17 | 6 | case Cases::NOMINATIVE: |
|
18 | 6 | case 'nominativus': |
|
19 | 5 | case 'n': |
|
20 | 1 | return Cases::NOMINATIVE; |
|
21 | |||
22 | 5 | case Cases::GENITIVE: |
|
23 | 5 | case Cases::GENETIVE: |
|
24 | 5 | case 'genetivus': |
|
25 | 4 | case 'g': |
|
26 | 1 | return Cases::GENITIVE; |
|
27 | |||
28 | 4 | case Cases::DATIVE: |
|
29 | 4 | case 'dativus': |
|
30 | 3 | case 'd': |
|
31 | 1 | return Cases::DATIVE; |
|
32 | |||
33 | 3 | case Cases::ACCUSATIVE: |
|
34 | return Cases::ACCUSATIVE; |
||
35 | |||
36 | 3 | case Cases::ABLATIVE: |
|
37 | 3 | case 'ablativus': |
|
38 | 2 | case 'a': |
|
39 | 1 | return Cases::ABLATIVE; |
|
40 | |||
41 | 2 | case Cases::PREPOSITIONAL: |
|
42 | 2 | case 'praepositionalis': |
|
43 | 1 | case 'p': |
|
44 | 1 | return Cases::PREPOSITIONAL; |
|
45 | |||
46 | default: |
||
47 | 1 | throw new InvalidArgumentException('Invalid case: '.$case); |
|
48 | } |
||
49 | } |
||
50 | |||
90 |