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

ExchangeUnbind   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 129
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

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

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 11 11 1
A getReserved1() 4 4 1
A getDestination() 4 4 1
A getSource() 4 4 1
A getRoutingKey() 4 4 1
A isNoWait() 4 4 1
A getArguments() 4 4 1
A encode() 12 12 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
 * Unbind an exchange from an exchange.
13
 *
14
 * @codeCoverageIgnore
15
 */
16 View Code Duplication
class ExchangeUnbind 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 int
20
     */
21
    private $reserved1;
22
23
    /**
24
     * @var string
25
     */
26
    private $destination;
27
28
    /**
29
     * @var string
30
     */
31
    private $source;
32
33
    /**
34
     * @var string
35
     */
36
    private $routingKey;
37
38
    /**
39
     * @var bool
40
     */
41
    private $noWait;
42
43
    /**
44
     * @var array
45
     */
46
    private $arguments = [];
47
48
    /**
49
     * @param int    $channel
50
     * @param int    $reserved1
51
     * @param string $destination
52
     * @param string $source
53
     * @param string $routingKey
54
     * @param bool   $noWait
55
     * @param array  $arguments
56
     */
57
    public function __construct($channel, $reserved1, $destination, $source, $routingKey, $noWait, $arguments)
58
    {
59
        $this->reserved1 = $reserved1;
60
        $this->destination = $destination;
61
        $this->source = $source;
62
        $this->routingKey = $routingKey;
63
        $this->noWait = $noWait;
64
        $this->arguments = $arguments;
65
66
        parent::__construct($channel);
67
    }
68
69
    /**
70
     * Reserved1.
71
     *
72
     * @return int
73
     */
74
    public function getReserved1()
75
    {
76
        return $this->reserved1;
77
    }
78
79
    /**
80
     * Destination.
81
     *
82
     * @return string
83
     */
84
    public function getDestination()
85
    {
86
        return $this->destination;
87
    }
88
89
    /**
90
     * Source.
91
     *
92
     * @return string
93
     */
94
    public function getSource()
95
    {
96
        return $this->source;
97
    }
98
99
    /**
100
     * Routing key of binding.
101
     *
102
     * @return string
103
     */
104
    public function getRoutingKey()
105
    {
106
        return $this->routingKey;
107
    }
108
109
    /**
110
     * NoWait.
111
     *
112
     * @return bool
113
     */
114
    public function isNoWait()
115
    {
116
        return $this->noWait;
117
    }
118
119
    /**
120
     * Arguments of binding.
121
     *
122
     * @return array
123
     */
124
    public function getArguments()
125
    {
126
        return $this->arguments;
127
    }
128
129
    /**
130
     * @return string
131
     */
132
    public function encode()
133
    {
134
        $data = "\x00\x28\x00\x28".
135
            Value\ShortValue::encode($this->reserved1).
136
            Value\ShortStringValue::encode($this->destination).
137
            Value\ShortStringValue::encode($this->source).
138
            Value\ShortStringValue::encode($this->routingKey).
139
            Value\BooleanValue::encode($this->noWait).
140
            Value\TableValue::encode($this->arguments);
141
142
        return "\x01".pack('nN', $this->channel, strlen($data)).$data."\xCE";
143
    }
144
}
145