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 ( 61c73d...4072b8 )
by Baptiste
03:56
created

FrameReader   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 9

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 9
dl 0
loc 45
ccs 0
cts 25
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B __invoke() 0 42 4
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\AMQP\Transport\Connection;
5
6
use Innmind\AMQP\{
7
    Transport\Protocol,
8
    Transport\Frame,
9
    Transport\Frame\Method,
10
    Transport\Frame\Type,
11
    Transport\Frame\Channel,
12
    Transport\Frame\Value\UnsignedOctet,
13
    Transport\Frame\Value\UnsignedShortInteger,
14
    Transport\Frame\Value\UnsignedLongInteger,
15
    Exception\ReceivedFrameNotDelimitedCorrectly,
16
    Exception\PayloadTooShort
17
};
18
use Innmind\Stream\Readable;
19
20
final class FrameReader
21
{
22
    public function __invoke(Readable $stream, Protocol $protocol): Frame
23
    {
24
        $type = Type::fromInt(
25
            UnsignedOctet::fromString($stream->read(1))->original()->value()
26
        );
27
        $channel = new Channel(
28
            UnsignedShortInteger::fromString($stream->read(2))->original()->value()
29
        );
30
        $payload = $stream
31
            ->read(UnsignedLongInteger::fromString($stream->read(4))->original()->value())
32
            ->toEncoding('ASCII');
33
34
        if ($payload->length() < 4) {
35
            throw new PayloadTooShort;
36
        }
37
38
        $end = $stream->read(1)->toEncoding('ASCII');
39
40
        if ($end->length() !== 1) {
41
            throw new ReceivedFrameNotDelimitedCorrectly;
42
        }
43
44
        $end = UnsignedOctet::fromString($end)->original()->value();
45
46
        if ($end !== 0xCE) {
47
            throw new ReceivedFrameNotDelimitedCorrectly;
48
        }
49
50
        $method = $payload->substring(0, 4);
51
        $method = new Method(
52
            UnsignedShortInteger::fromString($method->substring(0, 2))->original()->value(),
53
            UnsignedShortInteger::fromString($method->substring(2, 4))->original()->value()
54
        );
55
        $arguments = $payload->substring(4);
56
57
        return new Frame(
58
            $type,
59
            $channel,
60
            $method,
61
            ...$protocol->read($method, $arguments)
62
        );
63
    }
64
}
65