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

Queue::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\AMQP\Transport\Protocol\v091;
5
6
use Innmind\AMQP\{
7
    Model\Queue\Declaration,
8
    Model\Queue\Deletion,
9
    Model\Queue\Binding,
10
    Model\Queue\Unbinding,
11
    Model\Queue\Purge,
12
    Transport\Frame,
13
    Transport\Frame\Channel as FrameChannel,
14
    Transport\Frame\Type,
15
    Transport\Frame\Value,
16
    Transport\Frame\Value\UnsignedShortInteger,
17
    Transport\Frame\Value\ShortString,
18
    Transport\Frame\Value\Bits,
19
    Transport\Frame\Value\Table,
20
    Transport\Protocol\Queue as QueueInterface,
21
    Transport\Protocol\ArgumentTranslator
22
};
23
use Innmind\Math\Algebra\Integer;
24
use Innmind\Immutable\{
25
    Str,
26
    Map,
27
    MapInterface
28
};
29
30
final class Queue implements QueueInterface
31
{
32
    private $translate;
33
34 85
    public function __construct(ArgumentTranslator $translator)
35
    {
36 85
        $this->translate = $translator;
37 85
    }
38
39 6 View Code Duplication
    public function declare(FrameChannel $channel, Declaration $command): Frame
0 ignored issues
show
Coding Style introduced by
Possible parse error: non-abstract method defined as abstract
Loading history...
Duplication introduced by
This method 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...
40
    {
41 6
        $name = '';
42
43 6
        if (!$command->shouldAutoGenerateName()) {
44 1
            $name = $command->name();
45
        }
46
47 6
        return Frame::command(
48 6
            $channel,
49 6
            Methods::get('queue.declare'),
50 6
            new UnsignedShortInteger(new Integer(0)), //ticket (reserved)
51 6
            new ShortString(new Str($name)),
52 6
            new Bits(
53 6
                $command->isPassive(),
54 6
                $command->isDurable(),
55 6
                $command->isExclusive(),
56 6
                $command->isAutoDeleted(),
57 6
                !$command->shouldWait()
58
            ),
59 6
            $this->translate($command->arguments())
60
        );
61
    }
62
63 2
    public function delete(FrameChannel $channel, Deletion $command): Frame
64
    {
65 2
        return Frame::command(
66 2
            $channel,
67 2
            Methods::get('queue.delete'),
68 2
            new UnsignedShortInteger(new Integer(0)), //ticket (reserved)
69 2
            new ShortString(new Str($command->name())),
70 2
            new Bits(
71 2
                $command->onlyIfUnused(),
72 2
                $command->onlyIfEmpty(),
73 2
                !$command->shouldWait()
74
            )
75
        );
76
    }
77
78 2 View Code Duplication
    public function bind(FrameChannel $channel, Binding $command): Frame
0 ignored issues
show
Duplication introduced by
This method 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...
79
    {
80 2
        return Frame::command(
81 2
            $channel,
82 2
            Methods::get('queue.bind'),
83 2
            new UnsignedShortInteger(new Integer(0)), //ticket (reserved)
84 2
            new ShortString(new Str($command->queue())),
85 2
            new ShortString(new Str($command->exchange())),
86 2
            new ShortString(new Str($command->routingKey())),
87 2
            new Bits(!$command->shouldWait()),
88 2
            $this->translate($command->arguments())
89
        );
90
    }
91
92 2 View Code Duplication
    public function unbind(FrameChannel $channel, Unbinding $command): Frame
0 ignored issues
show
Duplication introduced by
This method 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...
93
    {
94 2
        return Frame::command(
95 2
            $channel,
96 2
            Methods::get('queue.unbind'),
97 2
            new UnsignedShortInteger(new Integer(0)), //ticket (reserved)
98 2
            new ShortString(new Str($command->queue())),
99 2
            new ShortString(new Str($command->exchange())),
100 2
            new ShortString(new Str($command->routingKey())),
101 2
            $this->translate($command->arguments())
102
        );
103
    }
104
105 2 View Code Duplication
    public function purge(FrameChannel $channel, Purge $command): Frame
0 ignored issues
show
Duplication introduced by
This method 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...
106
    {
107 2
        return Frame::command(
108 2
            $channel,
109 2
            Methods::get('queue.purge'),
110 2
            new UnsignedShortInteger(new Integer(0)), //ticket (reserved)
111 2
            new ShortString(new Str($command->name())),
112 2
            new Bits(!$command->shouldWait())
113
        );
114
    }
115
116
    /**
117
     * @param MapInterface<string, mixed> $arguments
118
     */
119 8 View Code Duplication
    private function translate(MapInterface $arguments): Table
0 ignored issues
show
Duplication introduced by
This method 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...
120
    {
121 8
        return new Table(
122 8
            $arguments->reduce(
123 8
                new Map('string', Value::class),
124 8
                function(Map $carry, string $key, $value): Map {
125 3
                    return $carry->put(
126 3
                        $key,
127 3
                        ($this->translate)($value)
128
                    );
129 8
                }
130
            )
131
        );
132
    }
133
}
134