Completed
Push — master ( 9bc3b7...a15851 )
by Harry
02:46
created

OptionalLoggerTrait::log()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 9.4285
cc 2
eloc 3
nc 2
nop 3
crap 2
1
<?php
2
3
namespace Graze\DataFile\Helper;
4
5
use Psr\Log\LoggerAwareTrait;
6
7
trait OptionalLoggerTrait
8
{
9
    use LoggerAwareTrait;
10
11
    /**
12
     * Send a log message only if we have a logger instantiated
13
     *
14
     * @param string $level
15
     * @param string $message
16
     * @param array  $context
17
     */
18 72
    protected function log($level, $message, array $context = [])
19
    {
20 72
        if ($this->logger) {
21 1
            $this->logger->log($level, __CLASS__ . ": " . $message, $context);
22
        }
23 72
    }
24
}
25