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 ( 4072b8...1c8336 )
by Baptiste
08:14 queued 02:38
created

FrameReader::__invoke()   B

Complexity

Conditions 4
Paths 4

Size

Total Lines 42
Code Lines 26

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 22
CRAP Score 4.0275

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 42
ccs 22
cts 25
cp 0.88
rs 8.5806
cc 4
eloc 26
nc 4
nop 2
crap 4.0275
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 1
    public function __invoke(Readable $stream, Protocol $protocol): Frame
23
    {
24 1
        $type = Type::fromInt(
25 1
            UnsignedOctet::fromString($stream->read(1))->original()->value()
26
        );
27 1
        $channel = new Channel(
28 1
            UnsignedShortInteger::fromString($stream->read(2))->original()->value()
29
        );
30
        $payload = $stream
31 1
            ->read(UnsignedLongInteger::fromString($stream->read(4))->original()->value())
32 1
            ->toEncoding('ASCII');
33
34 1
        if ($payload->length() < 4) {
35
            throw new PayloadTooShort;
36
        }
37
38 1
        $end = $stream->read(1)->toEncoding('ASCII');
39
40 1
        if ($end->length() !== 1) {
41
            throw new ReceivedFrameNotDelimitedCorrectly;
42
        }
43
44 1
        $end = UnsignedOctet::fromString($end)->original()->value();
45
46 1
        if ($end !== 0xCE) {
47
            throw new ReceivedFrameNotDelimitedCorrectly;
48
        }
49
50 1
        $method = $payload->substring(0, 4);
51 1
        $method = new Method(
52 1
            UnsignedShortInteger::fromString($method->substring(0, 2))->original()->value(),
53 1
            UnsignedShortInteger::fromString($method->substring(2, 4))->original()->value()
54
        );
55 1
        $arguments = $payload->substring(4);
56
57 1
        return new Frame(
58 1
            $type,
59 1
            $channel,
60 1
            $method,
61 1
            ...$protocol->read($method, $arguments)
62
        );
63
    }
64
}
65