1 | <?php |
||
17 | class Connection implements ConnectionInterface |
||
18 | { |
||
19 | /** |
||
20 | * @var AbstractConnection |
||
21 | */ |
||
22 | protected $resource; |
||
23 | /** |
||
24 | * @var ConnectionOptions |
||
25 | */ |
||
26 | protected $options; |
||
27 | /** |
||
28 | * @var Channel |
||
29 | */ |
||
30 | protected $channelPrototype; |
||
31 | |||
32 | /** |
||
33 | * Connection constructor. |
||
34 | * |
||
35 | * @param AbstractConnection|ConnectionOptions $connection |
||
36 | * @param Channel $channelPrototype |
||
37 | * @throws Exception\RuntimeException |
||
38 | * @throws Exception\InvalidArgumentException |
||
39 | * @throws Exception\BadMethodCallException |
||
40 | */ |
||
41 | 18 | public function __construct($connection, Channel $channelPrototype = null) |
|
51 | |||
52 | /** |
||
53 | * @return ConnectionOptions |
||
54 | */ |
||
55 | 9 | public function getOptions() |
|
59 | |||
60 | /** |
||
61 | * @param ConnectionOptions|Traversable|array $options |
||
62 | * @return $this |
||
63 | * @throws \AMQPAL\Exception\InvalidArgumentException |
||
64 | * @throws \AMQPAL\Exception\BadMethodCallException |
||
65 | * @throws Exception\InvalidArgumentException |
||
66 | * @throws Exception\BadMethodCallException |
||
67 | */ |
||
68 | 10 | public function setOptions($options) |
|
77 | |||
78 | /** |
||
79 | * @return AbstractConnection |
||
80 | * @throws Exception\RuntimeException |
||
81 | * @throws Exception\InvalidArgumentException |
||
82 | */ |
||
83 | 8 | protected function createResource() |
|
90 | |||
91 | /** |
||
92 | * @param AbstractConnection $resource |
||
93 | * @return $this |
||
94 | */ |
||
95 | 18 | public function setResource(AbstractConnection $resource) |
|
100 | |||
101 | /** |
||
102 | * @return AbstractConnection |
||
103 | */ |
||
104 | 10 | public function getResource() |
|
108 | |||
109 | /** |
||
110 | * Establish a connection with the AMQP broker. |
||
111 | * |
||
112 | * @return $this |
||
113 | * @throws Exception\RuntimeException |
||
114 | * @throws Exception\InvalidArgumentException |
||
115 | */ |
||
116 | 9 | public function connect() |
|
124 | |||
125 | /** |
||
126 | * Close any open connections and initiate a new one with the AMQP broker. |
||
127 | * |
||
128 | * @return $this |
||
129 | */ |
||
130 | 1 | public function reconnect() |
|
136 | |||
137 | /** |
||
138 | * Closes the connection with the AMQP broker. |
||
139 | * |
||
140 | * @return $this |
||
141 | * @throws Exception\RuntimeException |
||
142 | */ |
||
143 | 8 | public function disconnect() |
|
149 | |||
150 | /** |
||
151 | * Check whether the connection to the AMQP broker is still valid. |
||
152 | * |
||
153 | * @return bool |
||
154 | * @throws Exception\RuntimeException |
||
155 | */ |
||
156 | 10 | public function isConnected() |
|
160 | |||
161 | /** |
||
162 | * @param Channel $channel |
||
163 | */ |
||
164 | 18 | public function registerChannel(Channel $channel) |
|
168 | |||
169 | /** |
||
170 | * @param LibChannel $resource |
||
171 | * @return Channel |
||
172 | * @throws Exception\RuntimeException |
||
173 | * @throws Exception\InvalidArgumentException |
||
174 | */ |
||
175 | 10 | public function createChannel($resource = null) |
|
192 | } |
||
193 |