Conditions | 12 |
Paths | 12 |
Total Lines | 28 |
Code Lines | 23 |
Lines | 22 |
Ratio | 78.57 % |
Tests | 22 |
CRAP Score | 12.5239 |
Changes | 2 | ||
Bugs | 1 | Features | 1 |
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 |
||
33 | 22 | public function getPriority($assoc = 'left') |
|
34 | { |
||
35 | 22 | if ($assoc === 'right') { |
|
36 | 5 | View Code Duplication | switch ($this->value) { |
37 | 5 | case '^': |
|
38 | 1 | return 5; |
|
39 | 4 | case '/': |
|
40 | 1 | return 4; |
|
41 | 3 | case '*': |
|
42 | 1 | return 3; |
|
43 | 2 | case '-': |
|
44 | 1 | return 2; |
|
45 | 1 | case '+': |
|
46 | 1 | return 1; |
|
47 | } |
||
48 | } else { |
||
49 | 22 | View Code Duplication | switch ($this->value) { |
50 | 22 | case '^': |
|
51 | 10 | return 3; |
|
52 | 21 | case '*': |
|
53 | 21 | case '/': |
|
54 | 18 | return 2; |
|
55 | 15 | case '+': |
|
56 | 15 | case '-': |
|
57 | 15 | return 1; |
|
58 | } |
||
59 | } |
||
60 | } |
||
61 | |||
109 |