HasLoggerTrait::hasLogger()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: james
5
 * Date: 20/07/2018
6
 * Time: 11:14
7
 */
8
9
namespace CwsOps\LivePerson\Traits;
10
11
use Psr\Log\LoggerInterface;
12
use Psr\Log\NullLogger;
13
14
/**
15
 * @codeCoverageIgnore
16
 * Trait HasLoggerTrait
17
 *
18
 * @package CwsOps\LivePerson\Traits
19
 */
20
trait HasLoggerTrait
21
{
22
    /**
23
     * Quick method to check if a logger has been passed if not it will return a PSR NullLogger
24
     * @param LoggerInterface|null $logger
25
     *
26
     * @return LoggerInterface
27
     */
28
    protected function hasLogger(LoggerInterface $logger = null): LoggerInterface
29
    {
30
        if (null === $logger) {
31
            return new NullLogger();
32
        }
33
        return $logger;
34
    }
35
}
36