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.
Passed
Push — develop ( 404db9...8cc0dc )
by Baptiste
03:06 queued 15s
created

Basic::publish()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 11
nc 1
nop 1
dl 0
loc 16
ccs 11
cts 11
cp 1
crap 1
rs 9.9
c 0
b 0
f 0
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\AMQP\Client\Channel\Basic;
5
6
use Innmind\AMQP\{
7
    Client\Channel\Basic as BasicInterface,
8
    Model\Basic\Ack,
9
    Model\Basic\Cancel,
10
    Model\Basic\Consume,
11
    Model\Basic\Get as GetCommand,
12
    Model\Basic\Publish,
13
    Model\Basic\Qos,
14
    Model\Basic\Recover,
15
    Model\Basic\Reject,
16
    Model\Basic\Message\Locked,
17
    Transport\Connection,
18
    Transport\Connection\MessageReader,
19
    Transport\Frame,
20
    Transport\Frame\Channel,
21
};
22
use Innmind\TimeContinuum\ElapsedPeriod;
23
24
final class Basic implements BasicInterface
25
{
26
    private $connection;
27
    private $channel;
28
    private $read;
29
30 26
    public function __construct(Connection $connection, Channel $channel)
31
    {
32 26
        $this->connection = $connection;
33 26
        $this->channel = $channel;
34 26
        $this->read = new MessageReader;
35 26
    }
36
37 1
    public function ack(Ack $command): BasicInterface
38
    {
39 1
        $this->connection->send(
40 1
            $this->connection->protocol()->basic()->ack(
41 1
                $this->channel,
42 1
                $command
43
            )
44
        );
45
46 1
        return $this;
47
    }
48
49 2
    public function cancel(Cancel $command): BasicInterface
50
    {
51 2
        $this->connection->send(
52 2
            $this->connection->protocol()->basic()->cancel(
53 2
                $this->channel,
54 2
                $command
55
            )
56
        );
57
58 2
        if ($command->shouldWait()) {
59 1
            $this->connection->wait('basic.cancel-ok');
60
        }
61
62 2
        return $this;
63
    }
64
65 7
    public function consume(Consume $command): Consumer
66
    {
67 7
        $this->connection->send(
68 7
            $this->connection->protocol()->basic()->consume(
69 7
                $this->channel,
70 7
                $command
71
            )
72
        );
73
74 7
        if ($command->shouldWait()) {
75 7
            $frame = $this->connection->wait('basic.consume-ok');
76 7
            $consumerTag = (string) $frame->values()->first()->original();
77
        } else {
78
            $consumerTag = $command->consumerTag();
79
        }
80
81 7
        return new Consumer\Consumer(
82 7
            $this->connection,
83 7
            $command,
84 7
            $this->channel,
85 7
            $consumerTag
86
        );
87
    }
88
89 12
    public function get(GetCommand $command): Get
90
    {
91
        $frame = $this
92 12
            ->connection
93 12
            ->send($this->connection->protocol()->basic()->get(
94 12
                $this->channel,
95 12
                $command
96
            ))
97 12
            ->wait('basic.get-ok', 'basic.get-empty');
98
99 12
        if ($frame->is($this->connection->protocol()->method('basic.get-empty'))) {
100 4
            return new Get\GetEmpty;
101
        }
102
103 10
        $message = ($this->read)($this->connection);
104
105 10
        return new Get\GetOk(
106 10
            $this->connection,
107 10
            $this->channel,
108 10
            $command,
109 10
            new Locked($message),
110 10
            $frame->values()->first()->original()->value(), //deliveryTag
111 10
            $frame->values()->get(1)->original()->first(), //redelivered
112 10
            (string) $frame->values()->get(2)->original(), //exchange
113 10
            (string) $frame->values()->get(3)->original(), //routingKey
114 10
            $frame->values()->get(4)->original()->value() //messageCount
115
        );
116
    }
117
118 17
    public function publish(Publish $command): BasicInterface
119
    {
120
        $this
121 17
            ->connection
122 17
            ->protocol()
123 17
            ->basic()
124 17
            ->publish(
125 17
                $this->channel,
126 17
                $command,
127 17
                $this->connection->maxFrameSize()
128
            )
129
            ->foreach(function(Frame $frame): void {
130 17
                $this->connection->send($frame);
131 17
            });
132
133 17
        return $this;
134
    }
135
136 1
    public function qos(Qos $command): BasicInterface
137
    {
138
        $this
139 1
            ->connection
140 1
            ->send($this->connection->protocol()->basic()->qos(
141 1
                $this->channel,
142 1
                $command
143
            ))
144 1
            ->wait('basic.qos-ok');
145
146 1
        return $this;
147
    }
148
149
    public function recover(Recover $command): BasicInterface
150
    {
151
        $this
152
            ->connection
153
            ->send($this->connection->protocol()->basic()->recover(
154
                $this->channel,
155
                $command
156
            ))
157
            ->wait('basic.recover-ok');
158
159
        return $this;
160
    }
161
162 2
    public function reject(Reject $command): BasicInterface
163
    {
164 2
        $this->connection->send(
165 2
            $this->connection->protocol()->basic()->reject(
166 2
                $this->channel,
167 2
                $command
168
            )
169
        );
170
171 2
        return $this;
172
    }
173
}
174