Completed
Pull Request — master (#286)
by
unknown
03:20
created

ChannelCloseFrame   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 32
loc 32
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B create() 21 21 5

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
3
namespace PHPDaemon\Clients\AMQP\Driver\Protocol\v091\Protocol\Channel;
4
5
use PHPDaemon\Clients\AMQP\Driver\Protocol\v091\Protocol\IncomingFrame;
6
use PHPDaemon\Clients\AMQP\Driver\Protocol\v091\Protocol\MethodFrame;
7
use PHPDaemon\Clients\AMQP\Driver\Protocol\v091\Protocol\OutgoingFrame;
8
9
/**
10
 * Class ChannelCloseFrame
11
 * @author Aleksey I. Kuleshov YOU GLOBAL LIMITED
12
 * @package PHPDaemon\Clients\AMQP\Driver\Protocol\v091\Protocol\Channel
13
 */
14 View Code Duplication
class ChannelCloseFrame implements MethodFrame, IncomingFrame, OutgoingFrame
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...
15
{
16
    const METHOD_ID = 0x00140028;
17
18
    public $frameChannelId = 0;
19
    public $replyCode; // short
20
    public $replyText = ''; // shortstr
21
    public $classId; // short
22
    public $methodId; // short
23
24
    public static function create(
25
        $replyCode = null, $replyText = null, $classId = null, $methodId = null
26
    )
27
    {
28
        $frame = new self();
29
30
        if (null !== $replyCode) {
31
            $frame->replyCode = $replyCode;
32
        }
33
        if (null !== $replyText) {
34
            $frame->replyText = $replyText;
35
        }
36
        if (null !== $classId) {
37
            $frame->classId = $classId;
38
        }
39
        if (null !== $methodId) {
40
            $frame->methodId = $methodId;
41
        }
42
43
        return $frame;
44
    }
45
}
46