Completed
Push — master ( c92c53...bc5cbf )
by f
01:59
created

CasesHelper::canonizeCase()   D

Complexity

Conditions 25
Paths 25

Size

Total Lines 43
Code Lines 35

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 25
eloc 35
nc 25
nop 1
dl 0
loc 43
rs 4.7311
c 0
b 0
f 0

How to fix   Complexity   

Long Method

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:

1
<?php
2
namespace morphos\Russian;
3
4
trait CasesHelper {
5
    use \morphos\CasesHelper;
6
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