Skip to content

Commit e976906

Browse files
authored
Merge pull request vyuldashev#109 from vladimir-yuldashev/analysis-qygKrY
Apply fixes from StyleCI
2 parents 83ba2e2 + de7d18e commit e976906

File tree

6 files changed

+33
-42
lines changed

6 files changed

+33
-42
lines changed

src/VladimirYuldashev/LaravelQueueRabbitMQ/LaravelQueueRabbitMQServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function boot()
2929
{
3030
/** @var QueueManager $queue */
3131
$queue = $this->app['queue'];
32-
$connector = new RabbitMQConnector;
32+
$connector = new RabbitMQConnector();
3333

3434
$queue->stopping(function () use ($connector) {
3535
$connector->connection()->close();

src/VladimirYuldashev/LaravelQueueRabbitMQ/Queue/Connectors/RabbitMQConnector.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
class RabbitMQConnector implements ConnectorInterface
1010
{
11-
1211
/** @var AMQPStreamConnection */
1312
private $connection;
1413

@@ -40,5 +39,4 @@ public function connection()
4039
{
4140
return $this->connection;
4241
}
43-
4442
}

src/VladimirYuldashev/LaravelQueueRabbitMQ/Queue/RabbitMQQueue.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
use DateTime;
66
use ErrorException;
77
use Exception;
8-
use Log;
98
use Illuminate\Contracts\Queue\Queue as QueueContract;
109
use Illuminate\Queue\Queue;
10+
use Log;
1111
use PhpAmqpLib\Channel\AMQPChannel;
1212
use PhpAmqpLib\Connection\AMQPStreamConnection;
1313
use PhpAmqpLib\Message\AMQPMessage;
@@ -130,8 +130,6 @@ public function pushRaw($payload, $queue = null, array $options = [])
130130
} catch (ErrorException $exception) {
131131
$this->reportConnectionError('pushRaw', $exception);
132132
}
133-
134-
return null;
135133
}
136134

137135
/**
@@ -170,12 +168,9 @@ public function pop($queue = null)
170168
if ($message instanceof AMQPMessage) {
171169
return new RabbitMQJob($this->container, $this, $this->channel, $queue, $message);
172170
}
173-
}
174-
catch(ErrorException $exception) {
171+
} catch (ErrorException $exception) {
175172
$this->reportConnectionError('pop', $exception);
176173
}
177-
178-
return null;
179174
}
180175

181176
/**
@@ -326,9 +321,8 @@ public function getCorrelationId()
326321
*/
327322
private function reportConnectionError($action, Exception $e)
328323
{
329-
Log::error('AMQP error while attempting ' . $action . ': ' . $e->getMessage());
324+
Log::error('AMQP error while attempting '.$action.': '.$e->getMessage());
330325
// Sleep so that we don't flood the log file
331326
sleep($this->sleepOnError);
332327
}
333-
334328
}

src/config/rabbitmq.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
'host' => env('RABBITMQ_HOST', '127.0.0.1'),
1313
'port' => env('RABBITMQ_PORT', 5672),
1414

15-
'vhost' => env('RABBITMQ_VHOST', '/'),
16-
'login' => env('RABBITMQ_LOGIN', 'guest'),
15+
'vhost' => env('RABBITMQ_VHOST', '/'),
16+
'login' => env('RABBITMQ_LOGIN', 'guest'),
1717
'password' => env('RABBITMQ_PASSWORD', 'guest'),
1818

1919
'queue' => env('RABBITMQ_QUEUE'),
@@ -25,9 +25,9 @@
2525
// create the queue if not exists and bind to the exchange
2626

2727
'queue_params' => [
28-
'passive' => env('RABBITMQ_QUEUE_PASSIVE', false),
29-
'durable' => env('RABBITMQ_QUEUE_DURABLE', true),
30-
'exclusive' => env('RABBITMQ_QUEUE_EXCLUSIVE', false),
28+
'passive' => env('RABBITMQ_QUEUE_PASSIVE', false),
29+
'durable' => env('RABBITMQ_QUEUE_DURABLE', true),
30+
'exclusive' => env('RABBITMQ_QUEUE_EXCLUSIVE', false),
3131
'auto_delete' => env('RABBITMQ_QUEUE_AUTODELETE', false),
3232
],
3333
'exchange_params' => [

tests/RabbitMQConnectorTest.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,27 @@ class RabbitMQConnectorTest extends TestCase
1010
public function test_connect()
1111
{
1212
$config = [
13-
'host' => getenv('HOST'),
14-
'port' => getenv('PORT'),
15-
'login' => 'guest',
13+
'host' => getenv('HOST'),
14+
'port' => getenv('PORT'),
15+
'login' => 'guest',
1616
'password' => 'guest',
17-
'vhost' => '/',
17+
'vhost' => '/',
1818

19-
'queue' => 'queue_name',
20-
'exchange_declare' => true,
19+
'queue' => 'queue_name',
20+
'exchange_declare' => true,
2121
'queue_declare_bind' => true,
2222

2323
'queue_params' => [
24-
'passive' => false,
25-
'durable' => true,
26-
'exclusive' => false,
24+
'passive' => false,
25+
'durable' => true,
26+
'exclusive' => false,
2727
'auto_delete' => false,
2828
],
2929
'exchange_params' => [
30-
'name' => null,
31-
'type' => 'direct',
32-
'passive' => false,
33-
'durable' => true,
30+
'name' => null,
31+
'type' => 'direct',
32+
'passive' => false,
33+
'durable' => true,
3434
'auto_delete' => false,
3535
],
3636
];

tests/RabbitMQQueueTest.php

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use PhpAmqpLib\Connection\AMQPStreamConnection;
66
use PhpAmqpLib\Message\AMQPMessage;
77
use PHPUnit\Framework\TestCase;
8-
use VladimirYuldashev\LaravelQueueRabbitMQ\Queue\Jobs\RabbitMQJob;
98
use VladimirYuldashev\LaravelQueueRabbitMQ\Queue\RabbitMQQueue;
109

1110
/**
@@ -26,21 +25,21 @@ public function setUp()
2625
$this->connection->shouldReceive('channel')->andReturn($this->channel);
2726

2827
$this->config = [
29-
'queue' => str_random(),
28+
'queue' => str_random(),
3029
'queue_params' => [
31-
'passive' => false,
32-
'durable' => true,
33-
'exclusive' => false,
30+
'passive' => false,
31+
'durable' => true,
32+
'exclusive' => false,
3433
'auto_delete' => false,
3534
],
3635
'exchange_params' => [
37-
'name' => 'exchange_name',
38-
'type' => 'direct',
39-
'passive' => false,
40-
'durable' => true,
36+
'name' => 'exchange_name',
37+
'type' => 'direct',
38+
'passive' => false,
39+
'durable' => true,
4140
'auto_delete' => false,
4241
],
43-
'exchange_declare' => true,
42+
'exchange_declare' => true,
4443
'queue_declare_bind' => true,
4544
];
4645

@@ -111,9 +110,9 @@ public function test_later()
111110

112111
// delayed queue
113112
$this->channel->shouldReceive('queue_bind')->with(
114-
$this->config['queue'] . '_deferred_' . $delay,
113+
$this->config['queue'].'_deferred_'.$delay,
115114
$this->config['exchange_params']['name'],
116-
$this->config['queue'] . '_deferred_' . $delay
115+
$this->config['queue'].'_deferred_'.$delay
117116
)->once();
118117

119118
$this->channel->shouldReceive('basic_publish')->once();

0 commit comments

Comments
 (0)