Completed
Push — master ( 0f6cd0...ce5be5 )
by Florent
41:39 queued 33s
created

HasLogger::getLogger()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/*
4
 * The MIT License (MIT)
5
 *
6
 * Copyright (c) 2014-2016 Spomky-Labs
7
 *
8
 * This software may be modified and distributed under the terms
9
 * of the MIT license.  See the LICENSE file for details.
10
 */
11
12
namespace Jose\Behaviour;
13
14
use Psr\Log\LoggerInterface;
15
16
trait HasLogger
17
{
18
    /**
19
     * @var \Psr\Log\LoggerInterface
20
     */
21
    private $logger;
22
23
    /**
24
     * @return \Psr\Log\LoggerInterface
25
     */
26
    protected function getLogger()
27
    {
28
        return $this->logger;
29
    }
30
31
    /**
32
     * @param \Psr\Log\LoggerInterface $logger
33
     */
34
    private function setLogger(LoggerInterface $logger)
35
    {
36
        $this->logger = $logger;
37
    }
38
39
    /**
40
     * Logs with an arbitrary level.
41
     *
42
     * @param mixed $level
43
     * @param string $message
44
     * @param array $context
45
     *
46
     * @return null
47
     */
48
    private function log($level, $message, array $context = array())
49
    {
50
        if (null !== $this->logger) {
51
            $this->logger->log($level, $message, $context);
52
        }
53
    }
54
}
55