Conditions | 15 |
Paths | 15 |
Total Lines | 30 |
Code Lines | 27 |
Lines | 0 |
Ratio | 0 % |
Tests | 27 |
CRAP Score | 15 |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
74 | 2 | public static function fieldsOrder(array $field) |
|
75 | { |
||
76 | 2 | switch ($field['type']) { |
|
77 | 2 | case Field::HIDDEN_TYPE: |
|
78 | 2 | $order = 0; |
|
79 | 2 | break; |
|
80 | 2 | case Field::TEXT_TYPE: |
|
81 | 2 | case Field::PHONE_TYPE: |
|
82 | 2 | case Field::URL_TYPE: |
|
83 | 2 | case Field::PASSWORD_FIELD: |
|
84 | 2 | case Field::SEARCH_TYPE: |
|
85 | 2 | $order = 1; |
|
86 | 2 | break; |
|
87 | 2 | case Field::CHECK_TYPE: |
|
88 | 2 | case Field::RADIO_TYPE: |
|
89 | 2 | case Field::COMBO_TYPE: |
|
90 | 2 | case Field::NUMBER_TYPE: |
|
91 | 2 | case Field::SWITCH_TYPE: |
|
92 | 2 | $order = 2; |
|
93 | 2 | break; |
|
94 | 2 | case Field::TEXTAREA_TYPE: |
|
95 | 2 | $order = 3; |
|
96 | 2 | break; |
|
97 | default: |
||
98 | 2 | case Field::DATE: |
|
99 | 1 | case Field::TIMESTAMP: |
|
100 | 2 | $order = 4; |
|
101 | 2 | break; |
|
102 | } |
||
103 | 2 | return $order; |
|
104 | } |
||
106 |