Conditions | 10 |
Paths | 10 |
Total Lines | 25 |
Code Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 110 |
Changes | 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 |
||
96 | public static function transform( $status ) { |
||
97 | switch ( $status ) { |
||
98 | case self::PENDING: |
||
99 | case self::OPEN: |
||
100 | return Core_Statuses::OPEN; |
||
101 | |||
102 | case self::RESERVATION: |
||
103 | return Core_Statuses::RESERVED; |
||
104 | |||
105 | case self::SUCCESS: |
||
106 | return Core_Statuses::SUCCESS; |
||
107 | |||
108 | case self::CANCELLED: |
||
109 | return Core_Statuses::CANCELLED; |
||
110 | |||
111 | case self::EXPIRED: |
||
112 | return Core_Statuses::EXPIRED; |
||
113 | |||
114 | case self::DENIED: |
||
115 | case self::FAILURE: |
||
116 | return Core_Statuses::FAILURE; |
||
117 | |||
118 | case self::REVERSED: |
||
119 | default: |
||
120 | return null; |
||
121 | } |
||
124 |