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

Connection::close()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 0
cts 6
cp 0
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
crap 2
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\LongString,
10
    Transport\Frame\Value\ShortString,
11
    Transport\Frame\Value\Table,
12
    Transport\Frame\Value\UnsignedLongInteger,
13
    Transport\Frame\Value\UnsignedOctet,
14
    Transport\Frame\Value\UnsignedShortInteger,
15
    Transport\Protocol\v091\Methods,
16
    Exception\UnknownMethod
17
};
18
use Innmind\Immutable\{
19
    Str,
20
    StreamInterface
21
};
22
23
final class Connection
24
{
25
    /**
26
     * @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...
27
     */
28 1
    public function __invoke(Method $method, Str $arguments): StreamInterface
29
    {
30
        switch (true) {
31 1
            case Methods::get('connection.start')->equals($method):
32
                $visit = $this->start();
33
                break;
34
35
            case Methods::get('connection.secure')->equals($method):
36
                $visit = $this->secure();
37
                break;
38
39
            case Methods::get('connection.tune')->equals($method):
40
                $visit = $this->tune();
41
                break;
42
43
            case Methods::get('connection.open-ok')->equals($method):
44
                $visit = $this->openOk();
45
                break;
46
47
            case Methods::get('connection.close')->equals($method):
48
                $visit = $this->close();
49
                break;
50
51
            case Methods::get('connection.close-ok')->equals($method):
52
                $visit = $this->closeOk();
53
                break;
54
55
            default:
56
                throw new UnknownMethod($method);
57
        }
58
59
        return $visit($arguments);
60
    }
61
62
    private function start(): Arguments
63
    {
64
        return new Arguments(
65
            UnsignedOctet::class, //major version
66
            UnsignedOctet::class, //minor version
67
            Table::class, //server properties
68
            LongString::class, //mechanisms
69
            LongString::class //locales
70
        );
71
    }
72
73
    private function secure(): Arguments
74
    {
75
        return new Arguments(
76
            LongString::class //challenge
77
        );
78
    }
79
80
    private function tune(): Arguments
81
    {
82
        return new Arguments(
83
            UnsignedShortInteger::class, //max channels
84
            UnsignedLongInteger::class, //max frame size
85
            UnsignedShortInteger::class //heartbeat delay
86
        );
87
    }
88
89
    private function openOk(): Arguments
90
    {
91
        return new Arguments(
92
            ShortString::class //known hosts
93
        );
94
    }
95
96
    private function close(): Arguments
97
    {
98
        return new Arguments(
99
            UnsignedShortInteger::class, //reply code
100
            ShortString::class, //reply text
101
            UnsignedShortInteger::class, //failing class id
102
            UnsignedShortInteger::class //failing method id
103
        );
104
    }
105
106
    private function closeOk(): Arguments
107
    {
108
        return new Arguments; // no arguments
109
    }
110
}
111