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 ( 9ca54b...d40077 )
by Baptiste
01:45
created

Queue   B

Complexity

Total Complexity 8

Size/Duplication

Total Lines 109
Duplicated Lines 48.62 %

Coupling/Cohesion

Components 1
Dependencies 16

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 16
dl 53
loc 109
ccs 69
cts 69
cp 1
rs 8.4614
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
B declare() 0 24 2
A delete() 15 15 1
A bind() 14 14 1
A unbind() 13 13 1
A purge() 11 11 1
A translate() 0 14 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;
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
    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...
40
    {
41 6
        $name = '';
42
43 6
        if (!$command->shouldAutoGenerateName()) {
44 1
            $name = $command->name();
45
        }
46
47 6
        return new Frame(
48 6
            Type::method(),
49 6
            $channel,
50 6
            Methods::get('queue.declare'),
51 6
            new UnsignedShortInteger(new Integer(0)), //ticket (reserved)
52 6
            new ShortString(new Str($name)),
53 6
            new Bits(
54 6
                $command->isPassive(),
55 6
                $command->isDurable(),
56 6
                $command->isExclusive(),
57 6
                $command->isAutoDeleted(),
58 6
                !$command->shouldWait()
59
            ),
60 6
            $this->translate($command->arguments())
61
        );
62
    }
63
64 2 View Code Duplication
    public function delete(FrameChannel $channel, Deletion $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...
65
    {
66 2
        return new Frame(
67 2
            Type::method(),
68 2
            $channel,
69 2
            Methods::get('queue.delete'),
70 2
            new UnsignedShortInteger(new Integer(0)), //ticket (reserved)
71 2
            new ShortString(new Str($command->name())),
72 2
            new Bits(
73 2
                $command->onlyIfUnused(),
74 2
                $command->onlyIfEmpty(),
75 2
                !$command->shouldWait()
76
            )
77
        );
78
    }
79
80 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...
81
    {
82 2
        return new Frame(
83 2
            Type::method(),
84 2
            $channel,
85 2
            Methods::get('queue.bind'),
86 2
            new UnsignedShortInteger(new Integer(0)), //ticket (reserved)
87 2
            new ShortString(new Str($command->queue())),
88 2
            new ShortString(new Str($command->exchange())),
89 2
            new ShortString(new Str($command->routingKey())),
90 2
            new Bits(!$command->shouldWait()),
91 2
            $this->translate($command->arguments())
92
        );
93
    }
94
95 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...
96
    {
97 2
        return new Frame(
98 2
            Type::method(),
99 2
            $channel,
100 2
            Methods::get('queue.unbind'),
101 2
            new UnsignedShortInteger(new Integer(0)), //ticket (reserved)
102 2
            new ShortString(new Str($command->queue())),
103 2
            new ShortString(new Str($command->exchange())),
104 2
            new ShortString(new Str($command->routingKey())),
105 2
            $this->translate($command->arguments())
106
        );
107
    }
108
109 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...
110
    {
111 2
        return new Frame(
112 2
            Type::method(),
113 2
            $channel,
114 2
            Methods::get('queue.purge'),
115 2
            new UnsignedShortInteger(new Integer(0)), //ticket (reserved)
116 2
            new ShortString(new Str($command->name())),
117 2
            new Bits(!$command->shouldWait())
118
        );
119
    }
120
121
    /**
122
     * @param MapInterface<string, mixed> $arguments
123
     */
124 8
    private function translate(MapInterface $arguments): Table
125
    {
126 8
        return new Table(
127 8
            $arguments->reduce(
128 8
                new Map('string', Value::class),
129 8
                function(Map $carry, string $key, $value): Map {
130 3
                    return $carry->put(
131 3
                        $key,
132 3
                        ($this->translate)($value)
133
                    );
134 8
                }
135
            )
136
        );
137
    }
138
}
139