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 ( faae32...638f88 )
by Baptiste
03:29
created

Channel::__invoke()   B

Complexity

Conditions 6
Paths 6

Size

Total Lines 30
Code Lines 20

Duplication

Lines 30
Ratio 100 %

Code Coverage

Tests 2
CRAP Score 31.2848

Importance

Changes 0
Metric Value
dl 30
loc 30
ccs 2
cts 18
cp 0.1111
rs 8.439
c 0
b 0
f 0
cc 6
eloc 20
nc 6
nop 2
crap 31.2848
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\Arguments,
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\Immutable\{
16
    Str,
17
    StreamInterface
18
};
19
20 View Code Duplication
final class Channel
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
21
{
22
    /**
23
     * @return StreamInterface<Value>
0 ignored issues
show
Documentation introduced by
The doc-type StreamInterface<Value> could not be parsed: Expected "|" or "end of type", but got "<" at position 15. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
24
     */
25 1
    public function __invoke(Method $method, Str $arguments): StreamInterface
26
    {
27
        switch (true) {
28 1
            case Methods::get('channel.open-ok')->equals($method):
29
                $visit = $this->openOk();
30
                break;
31
32
            case Methods::get('channel.flow')->equals($method):
33
                $visit = $this->flow();
34
                break;
35
36
            case Methods::get('channel.flow-ok')->equals($method):
37
                $visit = $this->flowOk();
38
                break;
39
40
41
            case Methods::get('channel.close')->equals($method):
42
                $visit = $this->close();
43
                break;
44
45
            case Methods::get('channel.close-ok')->equals($method):
46
                $visit = $this->closeOk();
47
                break;
48
49
            default:
50
                throw new UnknownMethod($method);
51
        }
52
53
        return $visit($arguments);
54
    }
55
56
    private function openOk(): Arguments
57
    {
58
        return new Arguments; //no arguments
59
    }
60
61
    private function flow(): Arguments
62
    {
63
        return new Arguments(
64
            Bits::class //active
65
        );
66
    }
67
68
    private function flowOk(): Arguments
69
    {
70
        return new Arguments(
71
            Bits::class //active
72
        );
73
    }
74
75
    private function close(): Arguments
76
    {
77
        return new Arguments(
78
            UnsignedShortInteger::class, //reply code
79
            ShortString::class, //reply text
80
            UnsignedShortInteger::class, //failing class id
81
            UnsignedShortInteger::class //failing method id
82
        );
83
    }
84
85
    private function closeOk(): Arguments
86
    {
87
        return new Arguments; // no arguments
88
    }
89
}
90