Completed
Pull Request — master (#1)
by Daniel
12:19
created

SubscriberQueueBag::setExchange()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Cmobi\RabbitmqBundle\Transport\PubSub;
4
5
use Cmobi\RabbitmqBundle\Queue\QueueBagInterface;
6
7
class SubscriberQueueBag implements QueueBagInterface
8
{
9
    private $options;
10
11
    public function __construct(
12
        $exchange,
13
        $type = ExchangeType::FANOUT,
14
        $queueName = null,
15
        $basicQos = 1,
16
        $passive = false,
17
        $durable = false,
18
        $declareExclusive = true,
19
        $consumeExclusive = false,
20
        $internal = false,
21
        $autoDelete = false,
22
        $noWait = false,
23
        array $arguments = null,
24
        $ticket = null,
25
        $consumerTag = '',
26
        $noAck = true,
27
        $noLocal = false
28
    )
29
    {
30
        $this->options = [
31
            'exchange' => $exchange,
32
            'type' => $type,
33
            'basic_qos' => $basicQos,
34
            'queue_name' => $queueName,
35
            'passive' => $passive,
36
            'durable' => $durable,
37
            'declare_exclusive' => $declareExclusive,
38
            'consume_exclusive' => $consumeExclusive,
39
            'internal' => $internal,
40
            'auto_delete' => $autoDelete,
41
            'no_wait' => $noWait,
42
            'arguments' => $arguments,
43
            'ticket' => $ticket,
44
            'consumer_tag' => $consumerTag,
45
            'no_ack' => $noAck,
46
            'no_local' => $noLocal
47
        ];
48
    }
49
50
    /**
51
     * @param $exchange
52
     */
53
    public function setExchange($exchange)
54
    {
55
        $this->options['exchange'] = $exchange;
56
    }
57
58
    /**
59
     * @return string|mixed
60
     */
61
    public function getExchange()
62
    {
63
        return $this->options['exchange'];
64
    }
65
66
    /**
67
     * @param $qos
68
     */
69
    public function setBasicQos($qos)
70
    {
71
        $this->options['basic_qos'] = $qos;
72
    }
73
74
    /**
75
     * @return int
76
     */
77
    public function getBasicQos()
78
    {
79
        return $this->options['basic_qos'];
80
    }
81
82
    /**
83
     * @param $queueName
84
     */
85
    public function setQueueName($queueName)
86
    {
87
        $this->options['queue_name'] = $queueName;
88
    }
89
90
    /**
91
     * @return string
92
     */
93
    public function getQueueName()
94
    {
95
        return $this->options['queue_name'];
96
    }
97
98
    /**
99
     * @param $type
100
     */
101
    public function setType($type)
102
    {
103
        $this->options['type'] = $type;
104
    }
105
106
    /**
107
     * @return string
108
     */
109
    public function getType()
110
    {
111
        return $this->options['type'];
112
    }
113
114
    /**
115
     * @param $passive
116
     */
117
    public function setPassive($passive)
118
    {
119
        $this->options['passive'] = $passive;
120
    }
121
122
    /**
123
     * @return bool
124
     */
125
    public function getPassive()
126
    {
127
        return $this->options['passive'];
128
    }
129
130
    /**
131
     * @param $internal
132
     */
133
    public function setInternal($internal)
134
    {
135
        $this->options['internal'] = $internal;
136
    }
137
138
    /**
139
     * @return bool
140
     */
141
    public function getInternal()
142
    {
143
        return $this->options['internal'];
144
    }
145
146
    /**
147
     * @param $durable
148
     */
149
    public function setDurable($durable)
150
    {
151
        $this->options['durable'] = $durable;
152
    }
153
154
    /**
155
     * @return bool
156
     */
157
    public function getDurable()
158
    {
159
        return $this->options['durable'];
160
    }
161
162
    /**
163
     * @param $exclusive
164
     */
165
    public function setDeclareExclusive($exclusive)
166
    {
167
        $this->options['declare_exclusive'] = $exclusive;
168
    }
169
170
    /**
171
     * @return bool
172
     */
173
    public function getDeclareExclusive()
174
    {
175
        return $this->options['declare_exclusive'];
176
    }
177
178
    /**
179
     * @param $exclusive
180
     */
181
    public function setConsumeExclusive($exclusive)
182
    {
183
        $this->options['consume_exclusive'] = $exclusive;
184
    }
185
186
    /**
187
     * @return bool
188
     */
189
    public function getConsumeExclusive()
190
    {
191
        return $this->options['consume_exclusive'];
192
    }
193
194
    /**
195
     * @param $autoDelete
196
     */
197
    public function setAutoDelete($autoDelete)
198
    {
199
        $this->options['auto_delete'] = $autoDelete;
200
    }
201
202
    /**
203
     * @return bool
204
     */
205
    public function getAutoDelete()
206
    {
207
        return $this->options['auto_delete'];
208
    }
209
210
    /**
211
     * @param $noWait
212
     */
213
    public function setNoWait($noWait)
214
    {
215
        $this->options['no_wait'] = $noWait;
216
    }
217
218
    /**
219
     * @return bool
220
     */
221
    public function getNoWait()
222
    {
223
        return $this->options['no_wait'];
224
    }
225
226
    /**
227
     * @param array $arguments
228
     */
229
    public function setArguments(array $arguments)
230
    {
231
        $this->options['arguments'] = $arguments;
232
    }
233
234
    /**
235
     * @return string
236
     */
237
    public function getArguments()
238
    {
239
        return $this->options['arguments'];
240
    }
241
242
    /**
243
     * @param $ticket
244
     */
245
    public function setTicket($ticket)
246
    {
247
        $this->options['ticket'] = $ticket;
248
    }
249
250
    /**
251
     * @return string
252
     */
253
    public function getTicket()
254
    {
255
        return $this->options['ticket'];
256
    }
257
258
    /**
259
     * @param $consumerTag
260
     */
261
    public function setConsumerTag($consumerTag)
262
    {
263
        $this->options['consumer_tag'] = $consumerTag;
264
    }
265
266
    /**
267
     * @return string
268
     */
269
    public function getConsumerTag()
270
    {
271
        return $this->options['consumer_tag'];
272
    }
273
274
    /**
275
     * @param $noAck
276
     */
277
    public function setNoAck($noAck)
278
    {
279
        $this->options['no_ack'] = $noAck;
280
    }
281
282
    /**
283
     * @return bool
284
     */
285
    public function getNoAck()
286
    {
287
        return $this->options['no_ack'];
288
    }
289
290
    /**
291
     * @param $noLocal
292
     */
293
    public function setNoLocal($noLocal)
294
    {
295
        $this->options['no_local'] = $noLocal;
296
    }
297
298
    /**
299
     * @return bool
300
     */
301
    public function getNoLocal()
302
    {
303
        return $this->options['no_local'];
304
    }
305
306
    /**
307
     * @return array
308
     */
309
    public function getQueueDeclare()
310
    {
311
        return [
312
            $this->getQueueName(),
313
            $this->getPassive(),
314
            $this->getDurable(),
315
            $this->getDeclareExclusive(),
316
            $this->getAutoDelete(),
317
            $this->getNoWait(),
318
            $this->getArguments(),
319
            $this->getTicket()
320
        ];
321
    }
322
323
    /**
324
     * @return array
325
     */
326
    public function getQueueConsume()
327
    {
328
        return [
329
            $this->getQueueName(),
330
            $this->getConsumerTag(),
331
            $this->getNoLocal(),
332
            $this->getNoAck(),
333
            $this->getConsumeExclusive(),
334
            $this->getNoWait(),
335
            $this->getTicket(),
336
            $this->getArguments()
337
        ];
338
    }
339
340
    public function getExchangeDeclare()
341
    {
342
        return [
343
            $this->getExchange(),
344
            $this->getType(),
345
            $this->getPassive(),
346
            $this->getDurable(),
347
            $this->getAutoDelete(),
348
            $this->getInternal(),
349
            $this->getNoWait(),
350
            $this->getArguments(),
351
            $this->getTicket()
352
        ];
353
    }
354
355
    /**
356
     * @return string|mixed
357
     */
358
    public function getQueue()
359
    {
360
        return $this->getQueueName();
361
    }
362
363
    /**
364
     * @return bool
365
     */
366
    public function getExclusive()
367
    {
368
        return false;
369
    }
370
}