Completed
Push — master ( 7edb4c...18c0ae )
by Nikola
03:09
created

LoggerAwareTrait::getLogger()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 9.4286
cc 2
eloc 4
nc 2
nop 0
crap 2
1
<?php
2
/*
3
 * This file is part of the Exchange Rate package, an RunOpenCode project.
4
 *
5
 * (c) 2016 RunOpenCode
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace RunOpenCode\ExchangeRate\Log;
11
12
use Psr\Log\LoggerAwareTrait as BaseLoggerAwareTrait;
13
use Psr\Log\LoggerInterface;
14
use Psr\Log\NullLogger;
15
16
/**
17
 * Class LoggerAwareTrait
18
 *
19
 * Provides base logging capability. If logger is not provided, null logger will be initialized.
20
 *
21
 * @package RunOpenCode\ExchangeRate\Log
22
 */
23
trait LoggerAwareTrait
24
{
25
    use BaseLoggerAwareTrait;
26
27
    /**
28
     * Get logger. If logger does not exists, NullLogger will be provided.
29
     *
30
     * @return LoggerInterface
31
     */
32 2
    public function getLogger()
33
    {
34 2
        if ($this->logger === null) {
35 2
            $this->logger = new NullLogger();
36 2
        }
37
38 2
        return $this->logger;
39
    }
40
}