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.
Completed
Push — develop ( dc3756...ffde21 )
by Baptiste
06:26
created

Logger::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 2
crap 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\AMQP\Client\Channel\Basic\Get;
5
6
use Innmind\AMQP\{
7
    Client\Channel\Basic\Get,
8
    Model\Basic\Message,
9
    Exception\Reject,
10
    Exception\Requeue
11
};
12
use Psr\Log\LoggerInterface;
13
14
final class Logger implements Get
15
{
16
    private $get;
17
    private $logger;
18
19 6
    public function __construct(
20
        Get $get,
21
        LoggerInterface $logger
22
    ) {
23 6
        $this->get = $get;
24 6
        $this->logger = $logger;
25 6
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function __invoke(callable $consume): void
31
    {
32 4
        ($this->get)(function(Message $message, ...$args) use ($consume): void {
33
            try {
34 4
                $this->logger->debug(
35 4
                    'AMQP message received',
36 4
                    ['body' => (string) $message->body()]
37
                );
38
39 4
                $consume($message, ...$args);
40 3
            } catch (Reject $e) {
41 1
                $this->logger->warning(
42 1
                    'AMQP message rejected',
43 1
                    ['body' => (string) $message->body()]
44
                );
45 1
                throw $e;
46 2
            } catch (Requeue $e) {
47 1
                $this->logger->info(
48 1
                    'AMQP message requeued',
49 1
                    ['body' => (string) $message->body()]
50
                );
51 1
                throw $e;
52 1
            } catch (\Throwable $e) {
53 1
                $this->logger->error(
54 1
                    'AMQP message consumption generated an exception',
55
                    [
56 1
                        'body' => (string) $message->body(),
57 1
                        'exception' => get_class($e),
58
                    ]
59
                );
60 1
                throw $e;
61
            }
62 4
        });
63
    }
64
}
65