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