| Conditions | 16 |
| Paths | 16 |
| Total Lines | 22 |
| Lines | 0 |
| Ratio | 0 % |
| 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 |
||
| 7 | public static function make($errorCode, $errorMessage) |
||
| 8 | { |
||
| 9 | switch ($errorCode) { |
||
| 10 | case E_ERROR: return new Error($errorMessage, $errorCode); |
||
| 11 | case E_WARNING: return new Warning($errorMessage, $errorCode); |
||
| 12 | case E_PARSE: return new Parse($errorMessage, $errorCode); |
||
| 13 | case E_NOTICE: return new Notice($errorMessage, $errorCode); |
||
| 14 | case E_CORE_ERROR: return new CoreError($errorMessage, $errorCode); |
||
| 15 | case E_CORE_WARNING: return new CoreWarning($errorMessage, $errorCode); |
||
| 16 | case E_COMPILE_ERROR: return new CompileError($errorMessage, $errorCode); |
||
| 17 | case E_COMPILE_WARNING: return new CompileWarning($errorMessage, $errorCode); |
||
| 18 | case E_USER_ERROR: return new UserError($errorMessage, $errorCode); |
||
| 19 | case E_USER_WARNING: return new UserWarning($errorMessage, $errorCode); |
||
| 20 | case E_USER_NOTICE: return new UserNotice($errorMessage, $errorCode); |
||
| 21 | case E_STRICT: return new Strict($errorMessage, $errorCode); |
||
| 22 | case E_RECOVERABLE_ERROR: return new RecoverableError($errorMessage, $errorCode); |
||
| 23 | case E_DEPRECATED: return new Deprecated($errorMessage, $errorCode); |
||
| 24 | case E_USER_DEPRECATED: return new UserDeprecated($errorMessage, $errorCode); |
||
| 25 | } |
||
| 26 | |||
| 27 | return new Error($errorMessage, $errorCode); |
||
| 28 | } |
||
| 29 | } |
||
| 30 |