Logger_Syslog::log_error()   B
last analyzed

Complexity

Conditions 10
Paths 10

Size

Total Lines 23
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 10
eloc 18
c 0
b 0
f 0
nc 10
nop 5
dl 0
loc 23
rs 7.6666

How to fix   Complexity   

Long Method

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:

1
<?php
2
class Logger_Syslog {
3
4
    /**
5
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
6
     */
7
    public function log_error($errno, $errstr, $file, $line, $context) {
0 ignored issues
show
Unused Code introduced by
The parameter $context is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

7
    public function log_error($errno, $errstr, $file, $line, /** @scrutinizer ignore-unused */ $context) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
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
31
    }
32
33
}
34