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.

Basic::getOk()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 8
ccs 7
cts 7
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\AMQP\Transport\Protocol\v091\Reader;
5
6
use Innmind\AMQP\{
7
    Transport\Frame\Method,
8
    Transport\Frame\Visitor\ChunkArguments,
9
    Transport\Frame\Value\Bits,
10
    Transport\Frame\Value\ShortString,
11
    Transport\Frame\Value\UnsignedLongInteger,
12
    Transport\Frame\Value\UnsignedLongLongInteger,
13
    Transport\Frame\Value\UnsignedShortInteger,
14
    Transport\Protocol\v091\Methods,
15
    Exception\UnknownMethod,
16
};
17
use Innmind\Stream\Readable;
18
use Innmind\Immutable\StreamInterface;
19
20
final class Basic
21
{
22
    /**
23
     * @return StreamInterface<Value>
24
     */
25 74
    public function __invoke(Method $method, Readable $arguments): StreamInterface
26
    {
27
        switch (true) {
28 74
            case Methods::get('basic.qos-ok')->equals($method):
29 6
                $chunk = $this->qosOk();
30 6
                break;
31
32 68
            case Methods::get('basic.consume-ok')->equals($method):
33 22
                $chunk = $this->consumeOk();
34 22
                break;
35
36 62
            case Methods::get('basic.cancel-ok')->equals($method):
37 20
                $chunk = $this->cancelOk();
38 20
                break;
39
40 56
            case Methods::get('basic.return')->equals($method):
41 4
                $chunk = $this->return();
42 4
                break;
43
44 52
            case Methods::get('basic.deliver')->equals($method):
45 18
                $chunk = $this->deliver();
46 18
                break;
47
48 44
            case Methods::get('basic.get-ok')->equals($method):
49 30
                $chunk = $this->getOk();
50 30
                break;
51
52 18
            case Methods::get('basic.get-empty')->equals($method):
53 12
                $chunk = $this->getEmpty();
54 12
                break;
55
56 6
            case Methods::get('basic.recover-ok')->equals($method):
57 4
                $chunk = $this->recoverOk();
58 4
                break;
59
60
            default:
61 2
                throw new UnknownMethod($method);
62
        }
63
64 72
        return $chunk($arguments);
65
    }
66
67 6
    private function qosOk(): ChunkArguments
68
    {
69 6
        return new ChunkArguments; //no arguments
70
    }
71
72 22
    private function consumeOk(): ChunkArguments
73
    {
74 22
        return new ChunkArguments(
75 22
            ShortString::class //consumer tag
76
        );
77
    }
78
79 20
    private function cancelOk(): ChunkArguments
80
    {
81 20
        return new ChunkArguments(
82 20
            ShortString::class //consumer tag
83
        );
84
    }
85
86 4
    private function return(): ChunkArguments
87
    {
88 4
        return new ChunkArguments(
89 4
            UnsignedShortInteger::class, //reply code
90 4
            ShortString::class, //reply text
91 4
            ShortString::class, //exchange
92 4
            ShortString::class //routing key
93
        );
94
    }
95
96 18
    private function deliver(): ChunkArguments
97
    {
98 18
        return new ChunkArguments(
99 18
            ShortString::class, //consumer tag
100 18
            UnsignedLongLongInteger::class, //delivery tag
101 18
            Bits::class, //redelivered
102 18
            ShortString::class, //exchange
103 18
            ShortString::class //routing key
104
        );
105
    }
106
107 30
    private function getOk(): ChunkArguments
108
    {
109 30
        return new ChunkArguments(
110 30
            UnsignedLongLongInteger::class, //delivery tag
111 30
            Bits::class, //redelivered
112 30
            ShortString::class, //exchange
113 30
            ShortString::class, //routing key
114 30
            UnsignedLongInteger::class //message count
115
        );
116
    }
117
118 12
    private function getEmpty(): ChunkArguments
119
    {
120 12
        return new ChunkArguments; //no arguments
121
    }
122
123 4
    private function recoverOk(): ChunkArguments
124
    {
125 4
        return new ChunkArguments; //no arguments
126
    }
127
}
128