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.

Channel::close()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 22
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 16
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 15
nc 4
nop 2
dl 0
loc 22
ccs 16
cts 16
cp 1
crap 3
rs 9.7666
c 0
b 0
f 0
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\AMQP\Transport\Protocol\v091;
5
6
use Innmind\AMQP\{
7
    Model\Channel\Flow,
8
    Model\Channel\FlowOk,
9
    Model\Channel\Close,
10
    Transport\Protocol\Channel as ChannelInterface,
11
    Transport\Frame,
12
    Transport\Frame\Method,
13
    Transport\Frame\Channel as FrameChannel,
14
    Transport\Frame\Type,
15
    Transport\Frame\Value\ShortString,
16
    Transport\Frame\Value\Bits,
17
    Transport\Frame\Value\UnsignedShortInteger,
18
};
19
use Innmind\Math\Algebra\Integer;
20
use Innmind\Immutable\Str;
21
22
final class Channel implements ChannelInterface
23
{
24 86
    public function open(FrameChannel $channel): Frame
25
    {
26 86
        return Frame::method(
27 86
            $channel,
28 86
            Methods::get('channel.open'),
29 86
            new ShortString(new Str('')) //out of band (reserved)
30
        );
31
    }
32
33 2
    public function flow(FrameChannel $channel, Flow $command): Frame
34
    {
35 2
        return Frame::method(
36 2
            $channel,
37 2
            Methods::get('channel.flow'),
38 2
            new Bits($command->active())
39
        );
40
    }
41
42 2
    public function flowOk(FrameChannel $channel, FlowOk $command): Frame
43
    {
44 2
        return Frame::method(
45 2
            $channel,
46 2
            Methods::get('channel.flow-ok'),
47 2
            new Bits($command->active())
48
        );
49
    }
50
51 76
    public function close(FrameChannel $channel, Close $command): Frame
52
    {
53 76
        $replyCode = 0;
54 76
        $replyText = '';
55 76
        $method = new Method(0, 0);
56
57 76
        if ($command->hasReply()) {
58 2
            $replyCode = $command->replyCode();
59 2
            $replyText = $command->replyText();
60
        }
61
62 76
        if ($command->causedKnown()) {
63 2
            $method = Methods::get($command->cause());
64
        }
65
66 76
        return Frame::method(
67 76
            $channel,
68 76
            Methods::get('channel.close'),
69 76
            UnsignedShortInteger::of(new Integer($replyCode)),
70 76
            ShortString::of(new Str($replyText)),
71 76
            UnsignedShortInteger::of(new Integer($method->class())),
72 76
            UnsignedShortInteger::of(new Integer($method->method()))
73
        );
74
    }
75
76 2
    public function closeOk(FrameChannel $channel): Frame
77
    {
78 2
        return Frame::method(
79 2
            $channel,
80 2
            Methods::get('channel.close-ok')
81
        );
82
    }
83
}
84