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

OptionalLoggerAwareTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 20
rs 10
wmc 2
lcom 0
cbo 2

1 Method

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