Test Failed
Push — master ( a92e12...446184 )
by Domenico
04:27
created

CommandHandlerLogger::log()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
crap 1
1
<?php
2
/**
3
 *  This file is part of the Simple S3 package.
4
 *
5
 * (c) Mauro Cassani<https://github.com/mauretto78>
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
12
namespace Matecat\SimpleS3\Components\Logger;
13
14
use Psr\Log\LoggerInterface;
15
use Matecat\SimpleS3\Commands\CommandHandler;
16
17
class CommandHandlerLogger
18
{
19
    /**
20
     * @var LoggerInterface
21
     */
22
    protected $logger;
23
24
    /**
25
     * Logger constructor.
26
     *
27
     * @param LoggerInterface $logger
28
     */
29 37
    public function __construct(LoggerInterface $logger)
30
    {
31 37
        $this->logger = $logger;
32 37
    }
33
34
    /**
35
     * @param CommandHandler $commandHandler
36
     * @param string $message
37
     * @param string $level
38
     */
39 33
    public function log(CommandHandler $commandHandler, $message, $level = 'info')
40
    {
41 33
        $msg = '['.get_class($commandHandler).'] ' . $message;
42 33
        $this->logger->{$level}($msg);
43 33
    }
44
45
    /**
46
     * @param \Exception $exception
47
     * @return bool
48
     */
49
    public function logExceptionAndReturnFalse(\Exception $exception)
50
    {
51
        $this->logger->error($exception->getMessage());
52
53
        return false;
54
    }
55
}
56