Conditions | 11 |
Paths | 11 |
Total Lines | 23 |
Code Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 132 |
Changes | 2 | ||
Bugs | 0 | 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 |
||
14 | protected function getStateFromCode($code) |
||
15 | { |
||
16 | switch ($code) { |
||
17 | case 'D': |
||
18 | case 'D1': |
||
19 | case 'D2': |
||
20 | case 'RG': |
||
21 | case 'DD': |
||
22 | case 'B': |
||
23 | case 'U': |
||
24 | case 'VC': |
||
25 | case 'RI': |
||
26 | case 'RR': |
||
27 | $state = DeliveryStatus::stateDelivered(); |
||
28 | break; |
||
29 | |||
30 | default: |
||
31 | $state = DeliveryStatus::stateInProgress(); |
||
32 | break; |
||
33 | } |
||
34 | |||
35 | return $state; |
||
36 | } |
||
37 | } |
||
38 |