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::flow()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 3
cts 3
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\UnsignedShortInteger,
12
    Transport\Protocol\v091\Methods,
13
    Exception\UnknownMethod,
14
};
15
use Innmind\Stream\Readable;
16
use Innmind\Immutable\StreamInterface;
17
18
final class Channel
19
{
20
    /**
21
     * @return StreamInterface<Value>
22
     */
23 106
    public function __invoke(Method $method, Readable $arguments): StreamInterface
24
    {
25
        switch (true) {
26 106
            case Methods::get('channel.open-ok')->equals($method):
27 88
                $chunk = $this->openOk();
28 88
                break;
29
30 92
            case Methods::get('channel.flow')->equals($method):
31 4
                $chunk = $this->flow();
32 4
                break;
33
34 88
            case Methods::get('channel.flow-ok')->equals($method):
35 4
                $chunk = $this->flowOk();
36 4
                break;
37
38
39 84
            case Methods::get('channel.close')->equals($method):
40 4
                $chunk = $this->close();
41 4
                break;
42
43 80
            case Methods::get('channel.close-ok')->equals($method):
44 78
                $chunk = $this->closeOk();
45 78
                break;
46
47
            default:
48 2
                throw new UnknownMethod($method);
49
        }
50
51 104
        return $chunk($arguments);
52
    }
53
54 88
    private function openOk(): ChunkArguments
55
    {
56 88
        return new ChunkArguments; //no arguments
57
    }
58
59 4
    private function flow(): ChunkArguments
60
    {
61 4
        return new ChunkArguments(
62 4
            Bits::class //active
63
        );
64
    }
65
66 4
    private function flowOk(): ChunkArguments
67
    {
68 4
        return new ChunkArguments(
69 4
            Bits::class //active
70
        );
71
    }
72
73 4
    private function close(): ChunkArguments
74
    {
75 4
        return new ChunkArguments(
76 4
            UnsignedShortInteger::class, //reply code
77 4
            ShortString::class, //reply text
78 4
            UnsignedShortInteger::class, //failing class id
79 4
            UnsignedShortInteger::class //failing method id
80
        );
81
    }
82
83 78
    private function closeOk(): ChunkArguments
84
    {
85 78
        return new ChunkArguments; // no arguments
86
    }
87
}
88