HasLoggerTrait   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 4
dl 0
loc 14
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A hasLogger() 0 6 2
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