Completed
Pull Request — master (#1)
by Sergey
04:51
created

BasicCancel   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 57
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 57
loc 57
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 7 7 1
A getConsumerTag() 4 4 1
A isNoWait() 4 4 1
A encode() 8 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
/*
3
 * This file is automatically generated.
4
 */
5
6
namespace ButterAMQP\AMQP091\Framing\Method;
7
8
use ButterAMQP\AMQP091\Framing\Frame;
9
use ButterAMQP\Value;
10
11
/**
12
 * End a queue consumer.
13
 *
14
 * @codeCoverageIgnore
15
 */
16 View Code Duplication
class BasicCancel extends Frame
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...
17
{
18
    /**
19
     * @var string
20
     */
21
    private $consumerTag;
22
23
    /**
24
     * @var bool
25
     */
26
    private $noWait;
27
28
    /**
29
     * @param int    $channel
30
     * @param string $consumerTag
31
     * @param bool   $noWait
32
     */
33
    public function __construct($channel, $consumerTag, $noWait)
34
    {
35
        $this->consumerTag = $consumerTag;
36
        $this->noWait = $noWait;
37
38
        parent::__construct($channel);
39
    }
40
41
    /**
42
     * ConsumerTag.
43
     *
44
     * @return string
45
     */
46
    public function getConsumerTag()
47
    {
48
        return $this->consumerTag;
49
    }
50
51
    /**
52
     * NoWait.
53
     *
54
     * @return bool
55
     */
56
    public function isNoWait()
57
    {
58
        return $this->noWait;
59
    }
60
61
    /**
62
     * @return string
63
     */
64
    public function encode()
65
    {
66
        $data = "\x00\x3C\x00\x1E".
67
            Value\ShortStringValue::encode($this->consumerTag).
68
            Value\BooleanValue::encode($this->noWait);
69
70
        return "\x01".pack('nN', $this->channel, strlen($data)).$data."\xCE";
71
    }
72
}
73