Producer::getClass()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace RabbitMqModule\Options;
4
5
use Zend\Stdlib\AbstractOptions;
6
7
/**
8
 * Class Producer
9
 * @package RabbitMqModule\Options
10
 */
11
class Producer extends AbstractOptions
12
{
13
    /**
14
     * @var string
15
     */
16
    protected $connection = 'default';
17
    /**
18
     * @var Exchange
19
     */
20
    protected $exchange;
21
    /**
22
     * @var Queue
23
     */
24
    protected $queue;
25
    /**
26
     * @var string
27
     */
28
    protected $class = 'RabbitMqModule\\Producer';
29
    /**
30
     * @var bool
31
     */
32
    protected $autoSetupFabricEnabled = true;
33
34
    /**
35
     * @return string
36
     */
37 2
    public function getConnection()
38
    {
39 2
        return $this->connection;
40
    }
41
42
    /**
43
     * @param string $connection
44
     *
45
     * @return $this
46
     */
47 2
    public function setConnection($connection)
48
    {
49 2
        $this->connection = $connection;
50
51 2
        return $this;
52
    }
53
54
    /**
55
     * @return Exchange
56
     */
57 2
    public function getExchange()
58
    {
59 2
        return $this->exchange;
60
    }
61
62
    /**
63
     * @param array|Exchange $exchange
64
     *
65
     * @return $this
66
     *
67
     * @throws \InvalidArgumentException
68
     */
69 3
    public function setExchange($exchange)
70
    {
71 3
        if (is_array($exchange)) {
72 2
            $exchange = new Exchange($exchange);
73 2
        }
74 3
        if (!$exchange instanceof Exchange) {
75 1
            throw new \InvalidArgumentException(
76
                'Parameter "exchange" should be array or an instance of Exchange options'
77 1
            );
78
        }
79 2
        $this->exchange = $exchange;
80
81 2
        return $this;
82
    }
83
84
    /**
85
     * @return Queue
86
     */
87 2
    public function getQueue()
88
    {
89 2
        return $this->queue;
90
    }
91
92
    /**
93
     * @param array|Queue $queue
94
     *
95
     * @return $this
96
     *
97
     * @throws \InvalidArgumentException
98
     */
99 3
    public function setQueue($queue)
100
    {
101 3
        if (is_array($queue)) {
102 2
            $queue = new Queue($queue);
103 2
        }
104 3
        if (!$queue instanceof Queue) {
105 1
            throw new \InvalidArgumentException(
106
                'Parameter "queue" should be array or an instance of Queue options'
107 1
            );
108
        }
109 2
        $this->queue = $queue;
110
111 2
        return $this;
112
    }
113
114
    /**
115
     * @return string
116
     */
117 1
    public function getClass()
118
    {
119 1
        return $this->class;
120
    }
121
122
    /**
123
     * @param string $class
124
     *
125
     * @return $this
126
     */
127 1
    public function setClass($class)
128
    {
129 1
        $this->class = $class;
130
131 1
        return $this;
132
    }
133
134
    /**
135
     * @return bool
136
     */
137 2
    public function isAutoSetupFabricEnabled()
138
    {
139 2
        return $this->autoSetupFabricEnabled;
140
    }
141
142
    /**
143
     * @param bool $autoSetupFabricEnabled
144
     *
145
     * @return $this
146
     */
147 2
    public function setAutoSetupFabricEnabled($autoSetupFabricEnabled)
148
    {
149 2
        $this->autoSetupFabricEnabled = $autoSetupFabricEnabled;
150
151 2
        return $this;
152
    }
153
}
154