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

Queue::__invoke()   B

Complexity

Conditions 6
Paths 6

Size

Total Lines 29
Code Lines 20

Duplication

Lines 29
Ratio 100 %

Code Coverage

Tests 18
CRAP Score 6

Importance

Changes 0
Metric Value
dl 29
loc 29
ccs 18
cts 18
cp 1
rs 8.439
c 0
b 0
f 0
cc 6
eloc 20
nc 6
nop 2
crap 6
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\ShortString,
10
    Transport\Frame\Value\UnsignedLongInteger,
11
    Transport\Protocol\v091\Methods,
12
    Exception\UnknownMethod
13
};
14
use Innmind\Immutable\{
15
    Str,
16
    StreamInterface
17
};
18
19 View Code Duplication
final class Queue
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...
20
{
21
    /**
22
     * @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...
23
     */
24 11
    public function __invoke(Method $method, Str $arguments): StreamInterface
25
    {
26
        switch (true) {
27 11
            case Methods::get('queue.declare-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...
28 2
                $visit = $this->declareOk();
29 2
                break;
30
31 9
            case Methods::get('queue.bind-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...
32 2
                $visit = $this->bindOk();
33 2
                break;
34
35 7
            case Methods::get('queue.unbind-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...
36 2
                $visit = $this->unbindOk();
37 2
                break;
38
39 5
            case Methods::get('queue.purge-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...
40 2
                $visit = $this->purgeOk();
41 2
                break;
42
43 3
            case Methods::get('queue.delete-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...
44 2
                $visit = $this->deleteOk();
45 2
                break;
46
47
            default:
48 1
                throw new UnknownMethod($method);
49
        }
50
51 10
        return $visit($arguments);
52
    }
53
54 2
    private function declareOk(): Arguments
55
    {
56 2
        return new Arguments(
57 2
            ShortString::class, //queue
58 2
            UnsignedLongInteger::class, //message count
59 2
            UnsignedLongInteger::class //consumer count
60
        );
61
    }
62
63 2
    private function bindOk(): Arguments
64
    {
65 2
        return new Arguments; //no arguments
66
    }
67
68 2
    private function unbindOk(): Arguments
69
    {
70 2
        return new Arguments; //no arguments
71
    }
72
73 2
    private function purgeOk(): Arguments
74
    {
75 2
        return new Arguments(
76 2
            UnsignedLongInteger::class //message count
77
        );
78
    }
79
80 2
    private function deleteOk(): Arguments
81
    {
82 2
        return new Arguments(
83 2
            UnsignedLongInteger::class //message count
84
        );
85
    }
86
}
87