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.

Queue::__invoke()   A
last analyzed

Complexity

Conditions 6
Paths 6

Size

Total Lines 28
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 18
CRAP Score 6

Importance

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