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

Basic::__construct()   A

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
dl 0
loc 6
c 0
b 0
f 0
ccs 5
cts 5
cp 1
rs 9.4285
cc 1
eloc 4
nc 1
nop 2
crap 1
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 20
    public function __construct(Connection $connection, Channel $channel)
31
    {
32 20
        $this->connection = $connection;
33 20
        $this->channel = $channel;
34 20
        $this->read = new MessageReader;
35 20
    }
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 11
    public function get(GetCommand $command): Get
90
    {
91
        $frame = $this
92 11
            ->connection
93 11
            ->send($this->connection->protocol()->basic()->get(
94 11
                $this->channel,
95 11
                $command
96
            ))
97 11
            ->wait('basic.get-ok', 'basic.get-empty');
98
99 11
        if ($frame->method()->equals($this->connection->protocol()->method('basic.get-empty'))) {
100 4
            return new Get\GetEmpty;
101
        }
102
103 9
        $message = ($this->read)($this->connection);
104
105 9
        return new Get\GetOk(
106 9
            $this->connection,
107 9
            $this->channel,
108 9
            $command,
109 9
            new Locked($message),
110 9
            $frame->values()->first()->original()->value(), //deliveryTag
111 9
            $frame->values()->get(1)->original()->first(), //redelivered
112 9
            (string) $frame->values()->get(2)->original(), //exchange
113 9
            (string) $frame->values()->get(3)->original(), //routingKey
114 9
            $frame->values()->get(4)->original()->value() //messageCount
115
        );
116
    }
117
118 16
    public function publish(Publish $command): BasicInterface
119
    {
120
        $this
121 16
            ->connection
122 16
            ->protocol()
123 16
            ->basic()
124 16
            ->publish(
125 16
                $this->channel,
126 16
                $command,
127 16
                $this->connection->maxFrameSize()
128
            )
129 16
            ->foreach(function(Frame $frame): void {
130 16
                $this->connection->send($frame);
131 16
            });
132
133 16
        return $this;
134
    }
135
136
    public function qos(Qos $command): BasicInterface
137
    {
138
        $this
139
            ->connection
140
            ->send($this->connection->protocol()->basic()->qos(
141
                $this->channel,
142
                $command
143
            ))
144
            ->wait('basic.qos-ok');
145
146
        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