Completed
Push — master ( 8a4ca9...acd23c )
by Marco
02:46
created

EcontrolLogger   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 32.14 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 71.43%

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 2
c 3
b 0
f 1
lcom 0
cbo 4
dl 9
loc 28
ccs 5
cts 7
cp 0.7143
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 9 17 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php namespace Comodojo\Extender\Log;
2
3
use \Monolog\Logger;
4
use \Monolog\Handler\NullHandler;
5
use \Comodojo\Extender\Log\ConsoleHandler;
6
7
/**
8
 * Create a logger instance for econtrol
9
 * 
10
 * @package     Comodojo extender
11
 * @author      Marco Giovinazzi <[email protected]>
12
 * @license     GPL-3.0+
13
 *
14
 * LICENSE:
15
 * 
16
 * This program is free software: you can redistribute it and/or modify
17
 * it under the terms of the GNU Affero General Public License as
18
 * published by the Free Software Foundation, either version 3 of the
19
 * License, or (at your option) any later version.
20
 *
21
 * This program is distributed in the hope that it will be useful,
22
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24
 * GNU Affero General Public License for more details.
25
 *
26
 * You should have received a copy of the GNU Affero General Public License
27
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
28
 */
29
30
class EcontrolLogger extends LogWrapper {
31
32
    /**
33
     * Create the logger
34
     *
35
     * @param string $level
36
     *
37
     * @return \Monolog\Logger
38
     */
39 3
    public static function create($level = false) {
40
41 3
        $logger = new Logger("econtrol");
42
43 3 View Code Duplication
        if ( empty($level) ) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
44
45
            $logger->pushHandler(new NullHandler(self::getLevel("ERROR")));
46
47
        } else {
48
49 3
            $logger->pushHandler(new ConsoleHandler(self::getLevel($level)));
50
51
        }
52
53 3
        return $logger;
54
55
    }
56
57
}