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 ( d40077...e71353 )
by Baptiste
03:40
created

FrameReader   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 14

Test Coverage

Coverage 96.3%

Importance

Changes 2
Bugs 1 Features 1
Metric Value
dl 0
loc 51
c 2
b 1
f 1
wmc 5
lcom 0
cbo 14
ccs 26
cts 27
cp 0.963
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B __invoke() 0 48 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 22
    public function __invoke(Readable $stream, Protocol $protocol): Frame
25
    {
26 22
        $octet = $stream->read(1);
27
28
        try {
29 22
            $type = Type::fromInt(
0 ignored issues
show
Unused Code introduced by
$type is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
30 22
                UnsignedOctet::fromString($octet)->original()->value()
31
            );
32 2
        } catch (UnknownFrameType $e) {
33 2
            throw new NoFrameDetected($octet->append((string) $stream->read()));
34
        }
35
36 21
        $channel = new Channel(
37 21
            UnsignedShortInteger::fromString($stream->read(2))->original()->value()
38
        );
39
        $payload = $stream
40 21
            ->read(UnsignedLongInteger::fromString($stream->read(4))->original()->value())
41 21
            ->toEncoding('ASCII');
42
43 21
        if ($payload->length() < 4) {
44 1
            throw new PayloadTooShort;
45
        }
46
47 20
        $end = $stream->read(1)->toEncoding('ASCII');
48
49 20
        if ($end->length() !== 1) {
50 2
            throw new ReceivedFrameNotDelimitedCorrectly;
51
        }
52
53 18
        $end = UnsignedOctet::fromString($end)->original()->value();
54
55 18
        if ($end !== 0xCE) {
56
            throw new ReceivedFrameNotDelimitedCorrectly;
57
        }
58
59 18
        $method = $payload->substring(0, 4);
60 18
        $method = new Method(
61 18
            UnsignedShortInteger::fromString($method->substring(0, 2))->original()->value(),
62 18
            UnsignedShortInteger::fromString($method->substring(2, 4))->original()->value()
63
        );
64 18
        $arguments = $payload->substring(4);
65
66 18
        return Frame::command(
67 18
            $channel,
68 18
            $method,
69 18
            ...$protocol->read($method, $arguments)
70
        );
71
    }
72
}
73