LoggableTrait::registerLogger()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 7
ccs 0
cts 6
cp 0
rs 9.4285
cc 2
eloc 4
nc 2
nop 2
crap 6
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