LoggableTrait   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 1
cbo 1
dl 0
loc 28
ccs 0
cts 6
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A registerLogger() 0 7 2
1
<?php
2
3
namespace Majora\Framework\Log;
4
5
use Psr\Log\LoggerInterface;
6
use Psr\Log\NullLogger;
7
8
/**
9
 * Provides an accessor to logger and debug mode
10
 */
11
trait LoggableTrait
12
{
13
    /**
14
     * @var LoggerInterface
15
     */
16
    protected $logger;
17
18
    /**
19
     * @var boolean
20
     */
21
    protected $debug;
22
23
    /**
24
     * register a logger and eventually debug mode into Loggable class
25
     *
26
     * @param  LoggerInterface $logger
27
     * @param  boolean         $debug
28
     *
29
     * @return self
30
     */
31
    public function registerLogger(LoggerInterface $logger = null, $debug = false)
32
    {
33
        $this->logger = $logger ?: new NullLogger();
34
        $this->debug = $debug;
35
36
        return $this;
37
    }
38
}
39