Test Failed
Push — master ( 7e410e...bf8e81 )
by Alexey
04:20
created

ErrorHandlerLogger   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 38
ccs 0
cts 14
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A handle() 0 11 2
1
<?php declare(strict_types = 1);
2
3
namespace Venta\Framework\ErrorHandler;
4
5
use Psr\Log\{
6
    LoggerInterface, LogLevel
7
};
8
use Whoops\Handler\Handler;
9
10
/**
11
 * Class ErrorHandlerLogger
12
 *
13
 * @package Venta\ErrorHandler
14
 */
15
class ErrorHandlerLogger extends Handler
16
{
17
18
    /**
19
     * Logger instance
20
     *
21
     * @var LoggerInterface
22
     */
23
    protected $logger;
24
25
    /**
26
     * ErrorHandlerLogger constructor.
27
     *
28
     * @param LoggerInterface $logger
0 ignored issues
show
Documentation introduced by
Should the type for parameter $logger not be \Psr\Log\LoggerInterface?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
29
     */
30
    public function __construct(LoggerInterface $logger)
31
    {
32
        $this->logger = $logger;
0 ignored issues
show
Documentation Bug introduced by
It seems like $logger of type object<Psr\Log\LoggerInterface> is incompatible with the declared type object<LoggerInterface> of property $logger.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
33
    }
34
35
    /**
36
     * Logging exception
37
     *
38
     * @return int
39
     */
40
    public function handle()
41
    {
42
        $e = $this->getException();
43
        $this->logger->log(
44
            $e instanceof \Error ? LogLevel::CRITICAL : LogLevel::ERROR,
45
            $e->getMessage(),
46
            ['exception' => $e]
47
        );
48
49
        return self::DONE;
50
    }
51
52
}