Completed
Push — master ( 2f7a99...5fa5de )
by Matze
10:42
created

LoggerTrait   A

Complexity

Total Complexity 19

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 4
Bugs 0 Features 1
Metric Value
wmc 19
c 4
b 0
f 1
lcom 0
cbo 1
dl 0
loc 31
rs 10
ccs 6
cts 6
cp 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setLogger() 0 4 1
A log() 0 4 1
1
<?php
2
3
namespace BrainExe\Core\Traits;
4
5
use BrainExe\Annotations\Annotations\Inject;
6
use Monolog\Logger;
7
8
/**
9
 * @api
10
 */
11
trait LoggerTrait
12
{
13
14
    use \Psr\Log\LoggerTrait;
15
16
    /**
17
     * @var Logger
18
     */
19
    private $logger;
20
21
    /**
22
     * @Inject("@logger")
23
     * @param Logger $logger
24
     */
25 5
    public function setLogger(Logger $logger)
26
    {
27 5
        $this->logger = $logger;
28 5
    }
29
30
    /**
31
     * Logs with an arbitrary level.
32
     *
33
     * @param mixed $level
34
     * @param string $message
35
     * @param array $context
36
     */
37 3
    public function log($level, $message, array $context = [])
38
    {
39 3
        $this->logger->log($level, $message, $context);
40 3
    }
41
}
42