ExchangeBind::setExchange()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 14
ccs 9
cts 9
cp 1
rs 9.4285
c 1
b 0
f 0
cc 3
eloc 8
nc 4
nop 1
crap 3
1
<?php
2
3
namespace RabbitMqModule\Options;
4
5
use Zend\Stdlib\AbstractOptions;
6
7
/**
8
 * Class ExchangeBind
9
 * @package RabbitMqModule\Options
10
 */
11
class ExchangeBind extends AbstractOptions
12
{
13
    /**
14
     * @var Exchange
15
     */
16
    protected $exchange;
17
    /**
18
     * @var array
19
     */
20
    protected $routingKeys = [];
21
22
    /**
23
     * @return Exchange
24
     */
25 3
    public function getExchange()
26
    {
27 3
        return $this->exchange;
28
    }
29
30
    /**
31
     * @param array|Exchange $exchange
32
     *
33
     * @return $this
34
     *
35
     * @throws \InvalidArgumentException
36
     */
37 4
    public function setExchange($exchange)
38
    {
39 4
        if (is_array($exchange)) {
40 2
            $exchange = new Exchange($exchange);
41 2
        }
42 4
        if (!$exchange instanceof Exchange) {
43 1
            throw new \InvalidArgumentException(
44
                'Parameter "exchange" should be array or an instance of Exchange options'
45 1
            );
46
        }
47 3
        $this->exchange = $exchange;
48
49 3
        return $this;
50
    }
51
52
    /**
53
     * @return array
54
     */
55 3
    public function getRoutingKeys()
56
    {
57 3
        return $this->routingKeys;
58
    }
59
60
    /**
61
     * @param array $routingKeys
62
     *
63
     * @return $this
64
     */
65 2
    public function setRoutingKeys($routingKeys)
66
    {
67 2
        $this->routingKeys = $routingKeys;
68
69 2
        return $this;
70
    }
71
}
72