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 ( 638f88...e189ab )
by Baptiste
01:40
created

Channel   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 70
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 11
lcom 0
cbo 4
dl 70
loc 70
ccs 34
cts 34
cp 1
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
B __invoke() 30 30 6
A openOk() 4 4 1
A flow() 6 6 1
A flowOk() 6 6 1
A close() 9 9 1
A closeOk() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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\Bits,
10
    Transport\Frame\Value\ShortString,
11
    Transport\Frame\Value\UnsignedShortInteger,
12
    Transport\Protocol\v091\Methods,
13
    Exception\UnknownMethod
14
};
15
use Innmind\Immutable\{
16
    Str,
17
    StreamInterface
18
};
19
20 View Code Duplication
final class Channel
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
21
{
22
    /**
23
     * @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...
24
     */
25 11
    public function __invoke(Method $method, Str $arguments): StreamInterface
26
    {
27
        switch (true) {
28 11
            case Methods::get('channel.open-ok')->equals($method):
1 ignored issue
show
Documentation introduced by
$method is of type object<Innmind\AMQP\Transport\Frame\Method>, but the function expects a object<self>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
29 2
                $visit = $this->openOk();
30 2
                break;
31
32 9
            case Methods::get('channel.flow')->equals($method):
1 ignored issue
show
Documentation introduced by
$method is of type object<Innmind\AMQP\Transport\Frame\Method>, but the function expects a object<self>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
33 2
                $visit = $this->flow();
34 2
                break;
35
36 7
            case Methods::get('channel.flow-ok')->equals($method):
1 ignored issue
show
Documentation introduced by
$method is of type object<Innmind\AMQP\Transport\Frame\Method>, but the function expects a object<self>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
37 2
                $visit = $this->flowOk();
38 2
                break;
39
40
41 5
            case Methods::get('channel.close')->equals($method):
1 ignored issue
show
Documentation introduced by
$method is of type object<Innmind\AMQP\Transport\Frame\Method>, but the function expects a object<self>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
42 2
                $visit = $this->close();
43 2
                break;
44
45 3
            case Methods::get('channel.close-ok')->equals($method):
1 ignored issue
show
Documentation introduced by
$method is of type object<Innmind\AMQP\Transport\Frame\Method>, but the function expects a object<self>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
46 2
                $visit = $this->closeOk();
47 2
                break;
48
49
            default:
50 1
                throw new UnknownMethod($method);
51
        }
52
53 10
        return $visit($arguments);
54
    }
55
56 2
    private function openOk(): Arguments
57
    {
58 2
        return new Arguments; //no arguments
59
    }
60
61 2
    private function flow(): Arguments
62
    {
63 2
        return new Arguments(
64 2
            Bits::class //active
65
        );
66
    }
67
68 2
    private function flowOk(): Arguments
69
    {
70 2
        return new Arguments(
71 2
            Bits::class //active
72
        );
73
    }
74
75 2
    private function close(): Arguments
76
    {
77 2
        return new Arguments(
78 2
            UnsignedShortInteger::class, //reply code
79 2
            ShortString::class, //reply text
80 2
            UnsignedShortInteger::class, //failing class id
81 2
            UnsignedShortInteger::class //failing method id
82
        );
83
    }
84
85 2
    private function closeOk(): Arguments
86
    {
87 2
        return new Arguments; // no arguments
88
    }
89
}
90