GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

ErrorLogSubscriber   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 65.38%

Importance

Changes 0
Metric Value
wmc 6
c 0
b 0
f 0
lcom 0
cbo 2
dl 0
loc 46
ccs 17
cts 26
cp 0.6538
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A onReject() 0 4 1
A format() 0 19 4
A getSubscribedEvents() 0 6 1
1
<?php
2
3
namespace Bernard\EventListener;
4
5
use Bernard\Event\RejectEnvelopeEvent;
6
use Bernard\Envelope;
7
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
8
use Exception;
9
use Throwable;
10
11
class ErrorLogSubscriber implements EventSubscriberInterface
12
{
13
    /**
14
     * @param RejectEnvelopeEvent $event
15
     */
16 2
    public function onReject(RejectEnvelopeEvent $event)
17
    {
18 2
        error_log($this->format($event->getEnvelope(), $event->getException()));
19 2
    }
20
21
    /**
22
     * @param Envelope $envelope
23
     * @param mixed    $exception
24
     *
25
     * @return string
26
     */
27 2
    protected function format(Envelope $envelope, $exception)
28
    {
29 2
        if ($exception instanceof Exception || $exception instanceof Throwable) {
0 ignored issues
show
Bug introduced by
The class Throwable does not exist. Is this class maybe located in a folder that is not analyzed, or in a newer version of your dependencies than listed in your composer.lock/composer.json?
Loading history...
30
            $replacements = [
31 1
                '{class}' => get_class($exception),
32 1
                '{message}' => $exception->getMessage(),
33 1
                '{envelope}' => $envelope->getName(),
34 1
            ];
35
36 1
            return strtr('[bernard] caught exception {class}::{message} while processing {envelope}.', $replacements);
37
        }
38
39
        $replacements = [
40 1
            '{type}' => is_object($exception) ? get_class($exception) : gettype($exception),
41 1
            '{envelope}' => $envelope->getName(),
42 1
        ];
43
44 1
        return strtr('[bernard] caught unknown error type {type} while processing {envelope}.', $replacements);
45
    }
46
47
    /**
48
     * @return array
49
     */
50 1
    public static function getSubscribedEvents()
51
    {
52
        return [
53 1
            'bernard.reject' => ['onReject'],
54 1
        ];
55
    }
56
}
57