Conditions | 10 |
Paths | 10 |
Total Lines | 23 |
Code Lines | 18 |
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 function log_error($errno, $errstr, $file, $line, $context) { |
||
|
|||
8 | |||
9 | switch ($errno) { |
||
10 | case E_ERROR: |
||
11 | case E_PARSE: |
||
12 | case E_CORE_ERROR: |
||
13 | case E_COMPILE_ERROR: |
||
14 | case E_USER_ERROR: |
||
15 | $priority = LOG_ERR; |
||
16 | break; |
||
17 | case E_WARNING: |
||
18 | case E_CORE_WARNING: |
||
19 | case E_COMPILE_WARNING: |
||
20 | case E_USER_WARNING: |
||
21 | $priority = LOG_WARNING; |
||
22 | break; |
||
23 | default: |
||
24 | $priority = LOG_INFO; |
||
25 | } |
||
26 | |||
27 | $errname = Logger::$errornames[$errno]." ($errno)"; |
||
28 | |||
29 | syslog($priority, "[tt-rss] $errname ($file:$line) $errstr"); |
||
30 | |||
34 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.