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.

GetOk::requeue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 6
ccs 5
cts 5
cp 1
crap 1
rs 10
c 0
b 0
f 0
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\Get as Command,
9
    Model\Basic\Message,
10
    Model\Basic\Ack,
11
    Model\Basic\Reject as RejectCommand,
12
    Transport\Connection,
13
    Transport\Frame\Channel,
14
    Exception\Reject,
15
    Exception\Requeue,
16
};
17
18
final class GetOk implements Get
19
{
20
    private $connection;
21
    private $channel;
22
    private $command;
23
    private $message;
24
    private $deliveryTag;
25
    private $redelivered;
26
    private $exchange;
27
    private $routingKey;
28
    private $messageCount;
29
    private $consumed = false;
30
31 20
    public function __construct(
32
        Connection $connection,
33
        Channel $channel,
34
        Command $command,
35
        Message $message,
36
        int $deliveryTag,
37
        bool $redelivered,
38
        string $exchange,
39
        string $routingKey,
40
        int $messageCount
41
    ) {
42 20
        $this->connection = $connection;
43 20
        $this->channel = $channel;
44 20
        $this->command = $command;
45 20
        $this->message = $message;
46 20
        $this->deliveryTag = $deliveryTag;
47 20
        $this->redelivered = $redelivered;
48 20
        $this->exchange = $exchange;
49 20
        $this->routingKey = $routingKey;
50 20
        $this->messageCount = $messageCount;
51 20
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56 20
    public function __invoke(callable $consume): void
57
    {
58 20
        if ($this->consumed) {
59 2
            return;
60
        }
61
62
        try {
63 20
            $consume(
64 20
                $this->message,
65 20
                $this->redelivered,
66 20
                $this->exchange,
67 20
                $this->routingKey,
68 20
                $this->messageCount
69
            );
70
71 16
            if (!$this->command->shouldAutoAcknowledge()) {
72
                $this
73 16
                    ->connection
74 16
                    ->send($this->connection->protocol()->basic()->ack(
75 16
                        $this->channel,
76 16
                        new Ack($this->deliveryTag)
77
                    ));
78
            }
79
80 16
            $this->consumed = true;
81 6
        } catch (Reject $e) {
82 2
            $this->reject();
83 4
        } catch (Requeue $e) {
84 2
            $this->requeue();
85 2
        } catch (\Throwable $e) {
86 2
            $this->reject();
87
88 2
            throw $e;
89
        }
90 18
    }
91
92 4
    private function reject(): void
93
    {
94 4
        $this->connection->send(
95 4
            $this->connection->protocol()->basic()->reject(
96 4
                $this->channel,
97 4
                new RejectCommand($this->deliveryTag)
98
            )
99
        );
100 4
    }
101
102 2
    private function requeue(): void
103
    {
104 2
        $this->connection->send(
105 2
            $this->connection->protocol()->basic()->reject(
106 2
                $this->channel,
107 2
                RejectCommand::requeue($this->deliveryTag)
108
            )
109
        );
110 2
    }
111
}
112