Completed
Push — master ( 24f6ce...c3efa2 )
by Guilherme
05:36
created

OptionalLoggerAwareTrait::log()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
c 0
b 0
f 0
nc 2
nop 3
dl 0
loc 6
rs 9.4285
1
<?php
2
/**
3
 * This file is part of the login-cidadao project or it's bundles.
4
 *
5
 * (c) Guilherme Donato <guilhermednt on github>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace PROCERGS\Generic\Traits;
12
13
use Psr\Log\LoggerAwareTrait;
14
use Psr\Log\LoggerInterface;
15
16
trait OptionalLoggerAwareTrait
17
{
18
    use LoggerAwareTrait;
19
20
    /**
21
     * Logs with an arbitrary level if logger is available.
22
     *
23
     * @param mixed $level
24
     * @param string $message
25
     * @param array $context
26
     *
27
     * @return void
28
     */
29
    protected function log($level, $message, array $context = array())
30
    {
31
        if ($this->logger instanceof LoggerInterface) {
32
            $this->logger->log($level, $message, $context);
33
        }
34
    }
35
}
36