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 ( c3bf76...dc595a )
by Baptiste
03:31
created

FrameReader   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 14

Test Coverage

Coverage 96.43%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 5
c 1
b 0
f 1
lcom 0
cbo 14
dl 0
loc 52
ccs 27
cts 28
cp 0.9643
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B __invoke() 0 49 5
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
    Exception\UnknownFrameType,
18
    Exception\NoFrameDetected
19
};
20
use Innmind\Stream\Readable;
21
22
final class FrameReader
23
{
24 8
    public function __invoke(Readable $stream, Protocol $protocol): Frame
25
    {
26 8
        $octet = $stream->read(1);
27
28
        try {
29 8
            $type = Type::fromInt(
30 8
                UnsignedOctet::fromString($octet)->original()->value()
31
            );
32 2
        } catch (UnknownFrameType $e) {
33 2
            throw new NoFrameDetected($octet->append((string) $stream->read()));
34
        }
35
36 7
        $channel = new Channel(
37 7
            UnsignedShortInteger::fromString($stream->read(2))->original()->value()
38
        );
39
        $payload = $stream
40 7
            ->read(UnsignedLongInteger::fromString($stream->read(4))->original()->value())
41 7
            ->toEncoding('ASCII');
42
43 7
        if ($payload->length() < 4) {
44 1
            throw new PayloadTooShort;
45
        }
46
47 6
        $end = $stream->read(1)->toEncoding('ASCII');
48
49 6
        if ($end->length() !== 1) {
50 2
            throw new ReceivedFrameNotDelimitedCorrectly;
51
        }
52
53 4
        $end = UnsignedOctet::fromString($end)->original()->value();
54
55 4
        if ($end !== 0xCE) {
56
            throw new ReceivedFrameNotDelimitedCorrectly;
57
        }
58
59 4
        $method = $payload->substring(0, 4);
60 4
        $method = new Method(
61 4
            UnsignedShortInteger::fromString($method->substring(0, 2))->original()->value(),
62 4
            UnsignedShortInteger::fromString($method->substring(2, 4))->original()->value()
63
        );
64 4
        $arguments = $payload->substring(4);
65
66 4
        return new Frame(
67 4
            $type,
68 4
            $channel,
69 4
            $method,
70 4
            ...$protocol->read($method, $arguments)
71
        );
72
    }
73
}
74