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 ( a71c17...924269 )
by Baptiste
02:08
created

GetOk   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 94
Duplicated Lines 8.51 %

Coupling/Cohesion

Components 1
Dependencies 6

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 8
loc 94
c 0
b 0
f 0
wmc 9
lcom 1
cbo 6
ccs 46
cts 46
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 21 1
B __invoke() 8 35 6
A reject() 0 9 1
A requeue() 0 9 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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 9
    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 9
        $this->connection = $connection;
43 9
        $this->channel = $channel;
44 9
        $this->command = $command;
45 9
        $this->message = $message;
46 9
        $this->deliveryTag = $deliveryTag;
47 9
        $this->redelivered = $redelivered;
48 9
        $this->exchange = $exchange;
49 9
        $this->routingKey = $routingKey;
50 9
        $this->messageCount = $messageCount;
51 9
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56 9
    public function __invoke(callable $consume): void
57
    {
58 9
        if ($this->consumed) {
59 1
            return;
60
        }
61
62
        try {
63 9
            $consume(
64 9
                $this->message,
65 9
                $this->redelivered,
66 9
                $this->exchange,
67 9
                $this->routingKey,
68 9
                $this->messageCount
69
            );
70
71 7 View Code Duplication
            if (!$this->command->shouldAutoAcknowledge()) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
72
                $this
73 7
                    ->connection
74 7
                    ->send($this->connection->protocol()->basic()->ack(
75 7
                        $this->channel,
76 7
                        new Ack($this->deliveryTag)
77
                    ));
78
            }
79
80 7
            $this->consumed = true;
81 3
        } catch (Reject $e) {
82 1
            $this->reject();
83 2
        } catch (Requeue $e) {
84 1
            $this->requeue();
85 1
        } catch (\Throwable $e) {
86 1
            $this->reject();
87
88 1
            throw $e;
89
        }
90 8
    }
91
92 2
    private function reject(): void
93
    {
94 2
        $this->connection->send(
95 2
            $this->connection->protocol()->basic()->reject(
96 2
                $this->channel,
97 2
                new RejectCommand($this->deliveryTag)
98
            )
99
        );
100 2
    }
101
102 1
    private function requeue(): void
103
    {
104 1
        $this->connection->send(
105 1
            $this->connection->protocol()->basic()->reject(
106 1
                $this->channel,
107 1
                RejectCommand::requeue($this->deliveryTag)
108
            )
109
        );
110 1
    }
111
}
112