Completed
Push — master ( 7a3cb1...e42624 )
by Harry
9s
created

OptionalLoggerTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 18
ccs 5
cts 5
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A log() 0 6 2
1
<?php
2
/**
3
 * This file is part of graze/data-file
4
 *
5
 * Copyright (c) 2016 Nature Delivered Ltd. <https://www.graze.com>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @license https://github.com/graze/data-file/blob/master/LICENSE.md
11
 * @link    https://github.com/graze/data-file
12
 */
13
14
namespace Graze\DataFile\Helper;
15
16
use Psr\Log\LoggerAwareTrait;
17
18
trait OptionalLoggerTrait
19
{
20
    use LoggerAwareTrait;
21
22
    /**
23
     * Send a log message only if we have a logger instantiated
24
     *
25
     * @param string $level
26
     * @param string $message
27
     * @param array  $context
28
     */
29 78
    protected function log($level, $message, array $context = [])
30
    {
31 78
        if ($this->logger) {
32 1
            $this->logger->log($level, __CLASS__ . ": " . $message, $context);
33 1
        }
34 78
    }
35
}
36