Conditions | 17 |
Paths | 17 |
Total Lines | 30 |
Code Lines | 25 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
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 |
||
17 | function shutdownHandler() |
||
18 | { |
||
19 | // ログ処理 |
||
20 | if ($error = error_get_last()) { |
||
21 | $errorMsg = $error['message'] . " " . $error['file'] . "(" . $error['line'] . ")"; |
||
22 | switch ($error['type']) { |
||
23 | case E_ERROR: |
||
24 | case E_CORE_ERROR: |
||
25 | case E_COMPILE_ERROR: |
||
26 | case E_USER_ERROR: |
||
27 | case E_RECOVERABLE_ERROR: |
||
28 | Logger::fatal($errorMsg); |
||
29 | break; |
||
30 | case E_PARSE: |
||
31 | Logger::error($errorMsg); |
||
32 | break; |
||
33 | case E_WARNING: |
||
34 | case E_CORE_WARNING: |
||
35 | case E_COMPILE_WARNING: |
||
36 | case E_USER_WARNING: |
||
37 | case E_STRICT: |
||
38 | case E_NOTICE: |
||
39 | case E_USER_NOTICE: |
||
40 | case E_DEPRECATED: |
||
41 | case E_USER_DEPRECATED: |
||
42 | Logger::warn($errorMsg); |
||
43 | break; |
||
44 | } |
||
45 | } |
||
46 | } |
||
47 | } |
||
108 |