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.

Logger   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 27
dl 0
loc 47
ccs 25
cts 25
cp 1
rs 10
c 0
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A __invoke() 0 31 4
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 12
    public function __construct(
20
        Get $get,
21
        LoggerInterface $logger
22
    ) {
23 12
        $this->get = $get;
24 12
        $this->logger = $logger;
25 12
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30 8
    public function __invoke(callable $consume): void
31
    {
32
        ($this->get)(function(Message $message, ...$args) use ($consume): void {
33
            try {
34 8
                $this->logger->debug(
35 8
                    'AMQP message received',
36 8
                    ['body' => (string) $message->body()]
37
                );
38
39 8
                $consume($message, ...$args);
40 6
            } catch (Reject $e) {
41 2
                $this->logger->warning(
42 2
                    'AMQP message rejected',
43 2
                    ['body' => (string) $message->body()]
44
                );
45 2
                throw $e;
46 4
            } catch (Requeue $e) {
47 2
                $this->logger->info(
48 2
                    'AMQP message requeued',
49 2
                    ['body' => (string) $message->body()]
50
                );
51 2
                throw $e;
52 2
            } catch (\Throwable $e) {
53 2
                $this->logger->error(
54 2
                    'AMQP message consumption generated an exception',
55
                    [
56 2
                        'body' => (string) $message->body(),
57 2
                        'exception' => \get_class($e),
58
                    ]
59
                );
60 2
                throw $e;
61
            }
62 8
        });
63 8
    }
64
}
65