Skip to content

Commit ba21238

Browse files
committed
Code cleanup (PSR-2) and some refactoring
- Basic syntax checking and cleanup - Changed code for a little more consistency
1 parent a706636 commit ba21238

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/Codeception/Module/AMQP.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
<?php
2-
32
namespace Codeception\Module;
43

4+
use Codeception\Module as CodeceptionModule;
55
use Codeception\Exception\ModuleException as ModuleException;
6+
use Codeception\TestCase;
67
use Exception;
78
use PhpAmqpLib\Channel\AMQPChannel;
89
use PhpAmqpLib\Connection\AMQPConnection;
910
use PhpAmqpLib\Message\AMQPMessage;
11+
use PhpAmqpLib\Exception\AMQPProtocolChannelException;
1012

1113
/**
1214
* This module interacts with message broker software that implements
@@ -54,7 +56,7 @@
5456
5557
* @author davert
5658
*/
57-
class AMQP extends \Codeception\Module
59+
class AMQP extends CodeceptionModule
5860
{
5961
protected $config = [
6062
'host' => 'locahost',
@@ -87,12 +89,12 @@ public function _initialize()
8789

8890
try {
8991
$this->connection = new AMQPConnection($host, $port, $username, $password, $vhost);
90-
} catch (\Exception $e) {
92+
} catch (Exception $e) {
9193
throw new ModuleException(__CLASS__, $e->getMessage() . ' while establishing connection to MQ server');
9294
}
9395
}
9496

95-
public function _before(\Codeception\TestCase $test)
97+
public function _before(TestCase $test)
9698
{
9799
if ($this->config['cleanup']) {
98100
$this->cleanup();
@@ -200,8 +202,8 @@ protected function cleanup()
200202
foreach ($this->config['queues'] as $queue) {
201203
try {
202204
$this->connection->channel()->queue_purge($queue);
203-
} catch (\PhpAmqpLib\Exception\AMQPProtocolChannelException $e) {
204-
# ignore if exchange/queue doesn't exist and rethrow exception if it's something else
205+
} catch (AMQPProtocolChannelException $e) {
206+
// ignore if exchange/queue doesn't exist and rethrow exception if it's something else
205207
if ($e->getCode() !== 404) {
206208
throw $e;
207209
}

0 commit comments

Comments
 (0)