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 ( 414a11...09e31d )
by Baptiste
01:42
created

Channel   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 67
Duplicated Lines 64.18 %

Coupling/Cohesion

Components 0
Dependencies 12

Importance

Changes 0
Metric Value
dl 43
loc 67
c 0
b 0
f 0
wmc 7
lcom 0
cbo 12
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A open() 0 9 1
A flow() 9 9 1
A flowOk() 9 9 1
B close() 25 25 3
A closeOk() 0 8 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\Channel\Flow,
8
    Model\Channel\FlowOk,
9
    Model\Channel\Close,
10
    Transport\Protocol\Channel as ChannelInterface,
11
    Transport\Frame,
12
    Transport\Frame\Method,
13
    Transport\Frame\Channel as FrameChannel,
14
    Transport\Frame\Type,
15
    Transport\Frame\Value\ShortString,
16
    Transport\Frame\Value\Bits,
17
    Transport\Frame\Value\UnsignedShortInteger
18
};
19
use Innmind\Math\Algebra\Integer;
20
use Innmind\Immutable\Str;
21
22
final class Channel implements ChannelInterface
23
{
24
    public function open(FrameChannel $channel): Frame
25
    {
26
        return new Frame(
27
            Type::method(),
28
            $channel,
29
            Methods::get('channel.open'),
30
            new ShortString(new Str('')) //out of band (reserved)
31
        );
32
    }
33
34 View Code Duplication
    public function flow(FrameChannel $channel, Flow $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...
35
    {
36
        return new Frame(
37
            Type::method(),
38
            $channel,
39
            Methods::get('channel.flow'),
40
            new Bits($command->active())
41
        );
42
    }
43
44 View Code Duplication
    public function flowOk(FrameChannel $channel, FlowOk $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...
45
    {
46
        return new Frame(
47
            Type::method(),
48
            $channel,
49
            Methods::get('channel.flow-ok'),
50
            new Bits($command->active())
51
        );
52
    }
53
54 View Code Duplication
    public function close(FrameChannel $channel, Close $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...
55
    {
56
        $replyCode = 0;
57
        $replyText = '';
58
        $method = new Method(0, 0);
59
60
        if ($command->hasReply()) {
61
            $replyCode = $command->replyCode();
62
            $replyText = $command->replyText();
63
        }
64
65
        if ($command->causedKnown()) {
66
            $method = Methods::get($command->cause());
67
        }
68
69
        return new Frame(
70
            Type::method(),
71
            $channel,
72
            Methods::get('channel.close'),
73
            new UnsignedShortInteger(new Integer($replyCode)),
74
            new ShortString(new Str($replyText)),
75
            new UnsignedShortInteger(new Integer($method->class())),
76
            new UnsignedShortInteger(new Integer($method->method()))
77
        );
78
    }
79
80
    public function closeOk(FrameChannel $channel): Frame
81
    {
82
        return new Frame(
83
            Type::method(),
84
            $channel,
85
            Methods::get('channel.close-ok')
86
        );
87
    }
88
}
89