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

ExchangeDeclare::encode()   B

Complexity

Conditions 6
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 11
Ratio 100 %

Importance

Changes 0
Metric Value
dl 11
loc 11
rs 8.8571
c 0
b 0
f 0
cc 6
eloc 8
nc 1
nop 0
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
 * Verify exchange exists, create if needed.
13
 *
14
 * @codeCoverageIgnore
15
 */
16
class ExchangeDeclare extends Frame
17
{
18
    /**
19
     * @var int
20
     */
21
    private $reserved1;
22
23
    /**
24
     * @var string
25
     */
26
    private $exchange;
27
28
    /**
29
     * @var string
30
     */
31
    private $type;
32
33
    /**
34
     * @var bool
35
     */
36
    private $passive;
37
38
    /**
39
     * @var bool
40
     */
41
    private $durable;
42
43
    /**
44
     * @var bool
45
     */
46
    private $autoDelete;
47
48
    /**
49
     * @var bool
50
     */
51
    private $internal;
52
53
    /**
54
     * @var bool
55
     */
56
    private $noWait;
57
58
    /**
59
     * @var array
60
     */
61
    private $arguments = [];
62
63
    /**
64
     * @param int    $channel
65
     * @param int    $reserved1
66
     * @param string $exchange
67
     * @param string $type
68
     * @param bool   $passive
69
     * @param bool   $durable
70
     * @param bool   $autoDelete
71
     * @param bool   $internal
72
     * @param bool   $noWait
73
     * @param array  $arguments
74
     */
75 View Code Duplication
    public function __construct($channel, $reserved1, $exchange, $type, $passive, $durable, $autoDelete, $internal, $noWait, $arguments)
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...
76
    {
77
        $this->reserved1 = $reserved1;
78
        $this->exchange = $exchange;
79
        $this->type = $type;
80
        $this->passive = $passive;
81
        $this->durable = $durable;
82
        $this->autoDelete = $autoDelete;
83
        $this->internal = $internal;
84
        $this->noWait = $noWait;
85
        $this->arguments = $arguments;
86
87
        parent::__construct($channel);
88
    }
89
90
    /**
91
     * Reserved1.
92
     *
93
     * @return int
94
     */
95
    public function getReserved1()
96
    {
97
        return $this->reserved1;
98
    }
99
100
    /**
101
     * Exchange.
102
     *
103
     * @return string
104
     */
105
    public function getExchange()
106
    {
107
        return $this->exchange;
108
    }
109
110
    /**
111
     * Exchange type.
112
     *
113
     * @return string
114
     */
115
    public function getType()
116
    {
117
        return $this->type;
118
    }
119
120
    /**
121
     * Do not create exchange.
122
     *
123
     * @return bool
124
     */
125
    public function isPassive()
126
    {
127
        return $this->passive;
128
    }
129
130
    /**
131
     * Request a durable exchange.
132
     *
133
     * @return bool
134
     */
135
    public function isDurable()
136
    {
137
        return $this->durable;
138
    }
139
140
    /**
141
     * Auto-delete when unused.
142
     *
143
     * @return bool
144
     */
145
    public function isAutoDelete()
146
    {
147
        return $this->autoDelete;
148
    }
149
150
    /**
151
     * Create internal exchange.
152
     *
153
     * @return bool
154
     */
155
    public function isInternal()
156
    {
157
        return $this->internal;
158
    }
159
160
    /**
161
     * NoWait.
162
     *
163
     * @return bool
164
     */
165
    public function isNoWait()
166
    {
167
        return $this->noWait;
168
    }
169
170
    /**
171
     * Arguments for declaration.
172
     *
173
     * @return array
174
     */
175
    public function getArguments()
176
    {
177
        return $this->arguments;
178
    }
179
180
    /**
181
     * @return string
182
     */
183 View Code Duplication
    public function encode()
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...
184
    {
185
        $data = "\x00\x28\x00\x0A".
186
            Value\ShortValue::encode($this->reserved1).
187
            Value\ShortStringValue::encode($this->exchange).
188
            Value\ShortStringValue::encode($this->type).
189
            Value\OctetValue::encode(($this->passive ? 1 : 0) | (($this->durable ? 1 : 0) << 1) | (($this->autoDelete ? 1 : 0) << 2) | (($this->internal ? 1 : 0) << 3) | (($this->noWait ? 1 : 0) << 4)).
190
            Value\TableValue::encode($this->arguments);
191
192
        return "\x01".pack('nN', $this->channel, strlen($data)).$data."\xCE";
193
    }
194
}
195