| Conditions | 26 |
| Paths | 26 |
| Total Lines | 47 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 30 |
| CRAP Score | 27.9726 |
| 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 |
||
| 15 | 148 | public static function canonizeCase($case) |
|
| 16 | { |
||
| 17 | 148 | $case = S::lower($case); |
|
| 18 | switch ($case) { |
||
| 19 | 148 | case Cases::IMENIT: |
|
| 20 | 139 | case 'именительный': |
|
| 21 | 139 | case 'именит': |
|
| 22 | 139 | case 'и': |
|
| 23 | 24 | return Cases::IMENIT; |
|
| 24 | |||
| 25 | 139 | case Cases::RODIT: |
|
| 26 | 6 | case 'родительный': |
|
| 27 | 6 | case 'родит': |
|
| 28 | 6 | case 'р': |
|
| 29 | 133 | return Cases::RODIT; |
|
| 30 | |||
| 31 | 6 | case Cases::DAT: |
|
| 32 | 5 | case 'дательный': |
|
| 33 | 4 | case 'дат': |
|
| 34 | 4 | case 'д': |
|
| 35 | 2 | return Cases::DAT; |
|
| 36 | |||
| 37 | 4 | case Cases::VINIT: |
|
| 38 | 3 | case 'винительный': |
|
| 39 | 3 | case 'винит': |
|
| 40 | 3 | case 'в': |
|
| 41 | 1 | return Cases::VINIT; |
|
| 42 | |||
| 43 | 3 | case Cases::TVORIT: |
|
| 44 | 2 | case 'творительный': |
|
| 45 | 2 | case 'творит': |
|
| 46 | 2 | case 'т': |
|
| 47 | 1 | return Cases::TVORIT; |
|
| 48 | |||
| 49 | 2 | case Cases::PREDLOJ: |
|
| 50 | 1 | case 'предложный': |
|
| 51 | case 'предлож': |
||
| 52 | case 'п': |
||
| 53 | 2 | return Cases::PREDLOJ; |
|
| 54 | |||
| 55 | case Cases::LOCATIVE: |
||
| 56 | return Cases::LOCATIVE; |
||
| 57 | |||
| 58 | default: |
||
| 59 | return \morphos\CasesHelper::canonizeCase($case); |
||
| 60 | } |
||
| 61 | } |
||
| 62 | } |
||
| 63 |