Skip to content

Commit 54b48c4

Browse files
author
Mikhail Bakulin
committed
Binding options renamed for consistency
1 parent 011a00b commit 54b48c4

File tree

6 files changed

+22
-22
lines changed

6 files changed

+22
-22
lines changed

Configuration.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ class Configuration extends Component
7575
[
7676
'exchange' => null,
7777
'queue' => null,
78-
'toExchange' => null,
79-
'routingKeys' => [],
78+
'to_exchange' => null,
79+
'routing_keys' => [],
8080
],
8181
],
8282
'producers' => [
@@ -287,11 +287,11 @@ protected function validateRequired()
287287
if (!$this->isNameExist($this->exchanges, $binding['exchange'])) {
288288
throw new InvalidConfigException("`{$binding['exchange']}` defined in binding doesn't configured in exchanges.");
289289
}
290-
if (isset($binding['routingKeys']) && !is_array($binding['routingKeys'])) {
291-
throw new InvalidConfigException('Option `routingKeys` should be an array.');
290+
if (isset($binding['routing_keys']) && !is_array($binding['routing_keys'])) {
291+
throw new InvalidConfigException('Option `routing_keys` should be an array.');
292292
}
293-
if ((!isset($binding['queue']) && !isset($binding['toExchange'])) || isset($binding['queue'], $binding['toExchange'])) {
294-
throw new InvalidConfigException('Either `queue` or `toExchange` options should be specified to create binding.');
293+
if ((!isset($binding['queue']) && !isset($binding['to_exchange'])) || isset($binding['queue'], $binding['to_exchange'])) {
294+
throw new InvalidConfigException('Either `queue` or `to_exchange` options should be specified to create binding.');
295295
}
296296
if (isset($binding['queue']) && !$this->isNameExist($this->queues, $binding['queue'])) {
297297
throw new InvalidConfigException("`{$binding['queue']}` defined in binding doesn't configured in queues.");

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ return [
6666
[
6767
'queue' => 'YOUR_QUEUE_NAME',
6868
'exchange' => 'YOUR_EXCHANGE_NAME',
69-
'routingKeys' => ['YOUR_ROUTING_KEY'],
69+
'routing_keys' => ['YOUR_ROUTING_KEY'],
7070
],
7171
],
7272
'producers' => [
@@ -290,8 +290,8 @@ $rabbitmq_defaults = [
290290
[
291291
'exchange' => null,
292292
'queue' => null,
293-
'toExchange' => null,
294-
'routingKeys' => [],
293+
'to_exchange' => null,
294+
'routing_keys' => [],
295295
],
296296
],
297297
'producers' => [

components/Routing.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ public function declareBindings()
136136
*/
137137
public function bindExchangeToQueue(array $binding)
138138
{
139-
if (isset($binding['routingKeys']) && count($binding['routingKeys']) > 0) {
140-
foreach ($binding['routingKeys'] as $routingKey) {
139+
if (isset($binding['routing_keys']) && count($binding['routing_keys']) > 0) {
140+
foreach ($binding['routing_keys'] as $routingKey) {
141141
// queue binding is not permitted on the default exchange
142142
if ('' !== $binding['exchange']) {
143143
$this->conn->channel()->queue_bind($binding['queue'], $binding['exchange'], $routingKey);
@@ -157,17 +157,17 @@ public function bindExchangeToQueue(array $binding)
157157
*/
158158
public function bindExchangeToExchange(array $binding)
159159
{
160-
if (isset($binding['routingKeys']) && count($binding['routingKeys']) > 0) {
161-
foreach ($binding['routingKeys'] as $routingKey) {
160+
if (isset($binding['routing_keys']) && count($binding['routing_keys']) > 0) {
161+
foreach ($binding['routing_keys'] as $routingKey) {
162162
// queue binding is not permitted on the default exchange
163163
if ('' !== $binding['exchange']) {
164-
$this->conn->channel()->exchange_bind($binding['toExchange'], $binding['exchange'], $routingKey);
164+
$this->conn->channel()->exchange_bind($binding['to_exchange'], $binding['exchange'], $routingKey);
165165
}
166166
}
167167
} else {
168168
// queue binding is not permitted on the default exchange
169169
if ('' !== $binding['exchange']) {
170-
$this->conn->channel()->exchange_bind($binding['toExchange'], $binding['exchange']);
170+
$this->conn->channel()->exchange_bind($binding['to_exchange'], $binding['exchange']);
171171
}
172172
}
173173
}

tests/ConfigurationTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ public function invalidConfig()
7878
['Queue wrong field', array_merge($required, ['queues' => [['wrong' => 'wrong']]]), InvalidConfigException::class],
7979
['Exchange name is required for binding', array_merge($required, ['bindings' => [[]]]), InvalidConfigException::class],
8080
['Routing key is required for binding', array_merge($required, ['bindings' => [['exchange' => 'smth']]]), InvalidConfigException::class],
81-
['Either `queue` or `toExchange` options should be specified to create binding', array_merge($required, ['bindings' => [['exchange' => 'smth', 'routingKey' => 'smth',]]]), InvalidConfigException::class],
82-
['Exchanges and queues should be configured in corresponding sections', array_merge($required, ['bindings' => [['exchange' => 'smth', 'routingKey' => 'smth', 'queue' => 'smth',]]]), InvalidConfigException::class],
81+
['Either `queue` or `to_exchange` options should be specified to create binding', array_merge($required, ['bindings' => [['exchange' => 'smth', 'routing_keys' => ['smth'],]]]), InvalidConfigException::class],
82+
['Exchanges and queues should be configured in corresponding sections', array_merge($required, ['bindings' => [['exchange' => 'smth', 'routing_keys' => ['smth'], 'queue' => 'smth',]]]), InvalidConfigException::class],
8383
['Binding wrong field', array_merge($required, ['bindings' => [['wrong' => 'wrong']]]), InvalidConfigException::class],
8484
['Producer wrong field', array_merge($required, ['producers' => [['wrong' => 'wrong']]]), InvalidConfigException::class],
8585
['Producer name is required', array_merge($required, ['producers' => [[]]]), InvalidConfigException::class],

tests/DependencyInjectionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function testBootstrap()
4545
[
4646
'queue' => $name,
4747
'exchange' => $name,
48-
'routingKeys' => [$name],
48+
'routing_keys' => [$name],
4949
],
5050
],
5151
'producers' => [

tests/components/RoutingTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,20 @@ public function testRouting()
4343
[
4444
'queue' => $name,
4545
'exchange' => $name,
46-
'routingKeys' => [$name],
46+
'routing_keys' => [$name],
4747
],
4848
[
4949
'exchange' => $name,
50-
'toExchange' => $name,
51-
'routingKeys' => [$name],
50+
'to_exchange' => $name,
51+
'routing_keys' => [$name],
5252
],
5353
[
5454
'queue' => $name,
5555
'exchange' => $name,
5656
],
5757
[
5858
'exchange' => $name,
59-
'toExchange' => $name,
59+
'to_exchange' => $name,
6060
],
6161
[
6262
'queue' => '',

0 commit comments

Comments
 (0)