| 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 |
||
| 88 | public static function transform( $status ) { |
||
| 89 | switch ( $status ) { |
||
| 90 | case self::PENDING: |
||
| 91 | case self::OPEN: |
||
| 92 | return Core_Statuses::OPEN; |
||
| 93 | |||
| 94 | case self::RESERVATION: |
||
| 95 | return Core_Statuses::RESERVED; |
||
|
|
|||
| 96 | |||
| 97 | case self::SUCCESS: |
||
| 98 | return Core_Statuses::SUCCESS; |
||
| 99 | |||
| 100 | case self::CANCELLED: |
||
| 101 | return Core_Statuses::CANCELLED; |
||
| 102 | |||
| 103 | case self::EXPIRED: |
||
| 104 | return Core_Statuses::EXPIRED; |
||
| 105 | |||
| 106 | case self::DENIED: |
||
| 107 | case self::FAILURE: |
||
| 108 | return Core_Statuses::FAILURE; |
||
| 109 | |||
| 110 | case self::REVERSED: |
||
| 111 | default: |
||
| 112 | return null; |
||
| 113 | } |
||
| 116 |