Consumer::setAutoSetupFabricEnabled()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
3
namespace RabbitMqModule\Options;
4
5
use InvalidArgumentException;
6
use Zend\Stdlib\AbstractOptions;
7
8
/**
9
 * Class Consumer
10
 * @package RabbitMqModule\Options
11
 */
12
class Consumer extends AbstractOptions
13
{
14
    /**
15
     * @var string
16
     */
17
    protected $connection = 'default';
18
    /**
19
     * @var Exchange
20
     */
21
    protected $exchange;
22
    /**
23
     * @var Queue
24
     */
25
    protected $queue;
26
    /**
27
     * @var string|callable
28
     */
29
    protected $callback;
30
    /**
31
     * @var int
32
     */
33
    protected $idleTimeout;
34
    /**
35
     * @var string
36
     */
37
    protected $consumerTag;
38
    /**
39
     * @var Qos
40
     */
41
    protected $qos;
42
    /**
43
     * @var bool
44
     */
45
    protected $autoSetupFabricEnabled = true;
46
    /**
47
     * @var bool
48
     */
49
    protected $signalsEnabled = true;
50
    /**
51
     * @var string
52
     */
53
    protected $description;
54
55
    /**
56
     * @return string
57
     */
58 3
    public function getConnection()
59
    {
60 3
        return $this->connection;
61
    }
62
63
    /**
64
     * @param string $connection
65
     *
66
     * @return $this
67
     */
68 5
    public function setConnection($connection)
69
    {
70 5
        $this->connection = $connection;
71
72 5
        return $this;
73
    }
74
75
    /**
76
     * @return Exchange
77
     */
78 3
    public function getExchange()
79
    {
80 3
        return $this->exchange;
81
    }
82
83
    /**
84
     * @param array|Exchange $exchange
85
     *
86
     * @return $this
87
     *
88
     * @throws InvalidArgumentException
89
     */
90 6
    public function setExchange($exchange)
91
    {
92 6
        if (is_array($exchange)) {
93 5
            $exchange = new Exchange($exchange);
94 5
        }
95 6
        if (!$exchange instanceof Exchange) {
96 1
            throw new InvalidArgumentException(
97
                'Parameter "exchange" should be array or an instance of Exchange options'
98 1
            );
99
        }
100 5
        $this->exchange = $exchange;
101
102 5
        return $this;
103
    }
104
105
    /**
106
     * @return Queue
107
     */
108 3
    public function getQueue()
109
    {
110 3
        return $this->queue;
111
    }
112
113
    /**
114
     * @param array|Queue $queue
115
     *
116
     * @return $this
117
     */
118 6
    public function setQueue($queue)
119
    {
120 6
        if (is_array($queue)) {
121 5
            $queue = new Queue($queue);
122 5
        }
123 6
        if (!$queue instanceof Queue) {
124 1
            throw new InvalidArgumentException('Parameter "queue" should be array or an instance of Queue options');
125
        }
126 5
        $this->queue = $queue;
127
128 5
        return $this;
129
    }
130
131
    /**
132
     * @return string|callable
133
     */
134 5
    public function getCallback()
135
    {
136 5
        return $this->callback;
137
    }
138
139
    /**
140
     * @param string|callable $callback
141
     *
142
     * @return $this
143
     */
144 3
    public function setCallback($callback)
145
    {
146 3
        $this->callback = $callback;
147
148 3
        return $this;
149
    }
150
151
    /**
152
     * @return int
153
     */
154 3
    public function getIdleTimeout()
155
    {
156 3
        return $this->idleTimeout;
157
    }
158
159
    /**
160
     * @param int $idleTimeout
161
     *
162
     * @return $this
163
     */
164 5
    public function setIdleTimeout($idleTimeout)
165
    {
166 5
        $this->idleTimeout = $idleTimeout;
167
168 5
        return $this;
169
    }
170
171
    /**
172
     * @return string
173
     */
174 3
    public function getConsumerTag()
175
    {
176 3
        return $this->consumerTag;
177
    }
178
179
    /**
180
     * @param string $consumerTag
181
     *
182
     * @return $this
183
     */
184 1
    public function setConsumerTag($consumerTag)
185
    {
186 1
        $this->consumerTag = $consumerTag;
187
188 1
        return $this;
189
    }
190
191
    /**
192
     * @return Qos
193
     */
194 3
    public function getQos()
195
    {
196 3
        return $this->qos;
197
    }
198
199
    /**
200
     * @param array|Qos $qos
201
     *
202
     * @return $this
203
     */
204 6
    public function setQos($qos)
205
    {
206 6
        if (is_array($qos)) {
207 5
            $qos = new Qos($qos);
208 5
        }
209 6
        if (!$qos instanceof Qos) {
210 1
            throw new InvalidArgumentException('Parameter "qos" should be array or an instance of Qos options');
211
        }
212 5
        $this->qos = $qos;
213
214 5
        return $this;
215
    }
216
217
    /**
218
     * @return bool
219
     */
220 3
    public function isAutoSetupFabricEnabled()
221
    {
222 3
        return $this->autoSetupFabricEnabled;
223
    }
224
225
    /**
226
     * @param bool $autoSetupFabricEnabled
227
     *
228
     * @return $this
229
     */
230 1
    public function setAutoSetupFabricEnabled($autoSetupFabricEnabled)
231
    {
232 1
        $this->autoSetupFabricEnabled = $autoSetupFabricEnabled;
233
234 1
        return $this;
235
    }
236
237
    /**
238
     * @return bool
239
     */
240 1
    public function isSignalsEnabled()
241
    {
242 1
        return $this->signalsEnabled;
243
    }
244
245
    /**
246
     * @param bool $signalsEnabled
247
     *
248
     * @return $this
249
     */
250 1
    public function setSignalsEnabled($signalsEnabled)
251
    {
252 1
        $this->signalsEnabled = $signalsEnabled;
253
254 1
        return $this;
255
    }
256
257
    /**
258
     * @return string
259
     */
260
    public function getDescription()
261
    {
262
        return $this->description;
263
    }
264
265
    /**
266
     * @param string $description
267
     * @return $this
268
     */
269
    public function setDescription($description)
270
    {
271
        $this->description = $description;
272
        return $this;
273
    }
274
}
275