Skip to content

Commit d2d3ff5

Browse files
vyuldashevStyleCIBot
authored andcommitted
Applied fixes from StyleCI
1 parent bf4d4ba commit d2d3ff5

File tree

7 files changed

+77
-81
lines changed

7 files changed

+77
-81
lines changed

src/VladimirYuldashev/LaravelQueueRabbitMQ/LaravelQueueRabbitMQServiceProvider.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
class LaravelQueueRabbitMQServiceProvider extends ServiceProvider
99
{
10-
1110
/**
1211
* Register the service provider.
1312
*
@@ -16,7 +15,7 @@ class LaravelQueueRabbitMQServiceProvider extends ServiceProvider
1615
public function register()
1716
{
1817
$this->mergeConfigFrom(
19-
__DIR__ . '/../../config/rabbitmq.php', 'queue.connections.rabbitmq'
18+
__DIR__.'/../../config/rabbitmq.php', 'queue.connections.rabbitmq'
2019
);
2120
}
2221

@@ -28,12 +27,11 @@ public function register()
2827
public function boot()
2928
{
3029
/**
31-
* @var \Illuminate\Queue\QueueManager $manager
30+
* @var \Illuminate\Queue\QueueManager
3231
*/
3332
$manager = $this->app['queue'];
3433
$manager->addConnector('rabbitmq', function () {
35-
return new RabbitMQConnector;
34+
return new RabbitMQConnector();
3635
});
3736
}
38-
39-
}
37+
}

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

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,22 @@
88

99
class RabbitMQConnector implements ConnectorInterface
1010
{
11+
/**
12+
* Establish a queue connection.
13+
*
14+
* @param array $config
15+
*
16+
* @return \Illuminate\Contracts\Queue\Queue
17+
*/
18+
public function connect(array $config)
19+
{
20+
// create connection with AMQP
21+
$connection = new AMQPStreamConnection($config['host'], $config['port'], $config['login'], $config['password'],
22+
$config['vhost']);
1123

12-
/**
13-
* Establish a queue connection.
14-
*
15-
* @param array $config
16-
*
17-
* @return \Illuminate\Contracts\Queue\Queue
18-
*/
19-
public function connect(array $config)
20-
{
21-
// create connection with AMQP
22-
$connection = new AMQPStreamConnection($config['host'], $config['port'], $config['login'], $config['password'],
23-
$config['vhost']);
24-
25-
return new RabbitMQQueue(
26-
$connection,
27-
$config
28-
);
29-
}
30-
31-
}
24+
return new RabbitMQQueue(
25+
$connection,
26+
$config
27+
);
28+
}
29+
}

src/VladimirYuldashev/LaravelQueueRabbitMQ/Queue/Jobs/RabbitMQJob.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
class RabbitMQJob extends Job implements JobContract
1313
{
1414
/**
15-
* Same as RabbitMQQueue, used for attempt counts
15+
* Same as RabbitMQQueue, used for attempt counts.
1616
*/
1717
const ATTEMPT_COUNT_HEADERS_KEY = 'attempts_count';
1818

@@ -24,12 +24,11 @@ class RabbitMQJob extends Job implements JobContract
2424
/**
2525
* Creates a new instance of RabbitMQJob.
2626
*
27-
* @param Illuminate\Container\Container $container
27+
* @param Illuminate\Container\Container $container
2828
* @param VladimirYuldashev\LaravelQueueRabbitMQ\Queue\RabbitMQQueue $connection
29-
* @param PhpAmqpLib\Channel\AMQPChannel $channel
30-
* @param string $queue
31-
* @param PhpAmqpLib\Message\AMQPMessage $message
32-
*
29+
* @param PhpAmqpLib\Channel\AMQPChannel $channel
30+
* @param string $queue
31+
* @param PhpAmqpLib\Message\AMQPMessage $message
3332
*/
3433
public function __construct(
3534
Container $container,
@@ -99,7 +98,7 @@ public function getQueue()
9998
/**
10099
* Release the job back into the queue.
101100
*
102-
* @param int $delay
101+
* @param int $delay
103102
*
104103
* @return void
105104
*/
@@ -110,7 +109,7 @@ public function release($delay = 0)
110109

111110
$body = $this->getParsedBody();
112111

113-
/**
112+
/*
114113
* Some jobs don't have the command set, so fall back to just sending it the job name string
115114
*/
116115
if (isset($body['data']['command']) === true) {
@@ -142,6 +141,7 @@ public function attempts()
142141
return $headers[self::ATTEMPT_COUNT_HEADERS_KEY];
143142
}
144143
}
144+
145145
return 0;
146146
}
147147

src/VladimirYuldashev/LaravelQueueRabbitMQ/Queue/RabbitMQQueue.php

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
class RabbitMQQueue extends Queue implements QueueContract
1515
{
1616
/**
17-
* Used for retry logic, to set the retries on the message metadata instead of the message body
17+
* Used for retry logic, to set the retries on the message metadata instead of the message body.
1818
*/
1919
const ATTEMPT_COUNT_HEADERS_KEY = 'attempts_count';
2020

@@ -35,7 +35,7 @@ class RabbitMQQueue extends Queue implements QueueContract
3535

3636
/**
3737
* @param AMQPStreamConnection $amqpConnection
38-
* @param array $config
38+
* @param array $config
3939
*/
4040
public function __construct(AMQPStreamConnection $amqpConnection, $config)
4141
{
@@ -52,9 +52,9 @@ public function __construct(AMQPStreamConnection $amqpConnection, $config)
5252
/**
5353
* Push a new job onto the queue.
5454
*
55-
* @param string $job
56-
* @param mixed $data
57-
* @param string $queue
55+
* @param string $job
56+
* @param mixed $data
57+
* @param string $queue
5858
*
5959
* @return bool
6060
*/
@@ -66,9 +66,9 @@ public function push($job, $data = '', $queue = null)
6666
/**
6767
* Push a raw payload onto the queue.
6868
*
69-
* @param string $payload
70-
* @param string $queue
71-
* @param array $options
69+
* @param string $payload
70+
* @param string $queue
71+
* @param array $options
7272
*
7373
* @return mixed
7474
*/
@@ -83,7 +83,7 @@ public function pushRaw($payload, $queue = null, array $options = [])
8383
}
8484

8585
$headers = [
86-
'Content-Type' => 'application/json',
86+
'Content-Type' => 'application/json',
8787
'delivery_mode' => 2,
8888
];
8989

@@ -103,10 +103,10 @@ public function pushRaw($payload, $queue = null, array $options = [])
103103
/**
104104
* Push a new job onto the queue after a delay.
105105
*
106-
* @param \DateTime|int $delay
107-
* @param string $job
108-
* @param mixed $data
109-
* @param string $queue
106+
* @param \DateTime|int $delay
107+
* @param string $job
108+
* @param mixed $data
109+
* @param string $queue
110110
*
111111
* @return mixed
112112
*/
@@ -135,8 +135,6 @@ public function pop($queue = null)
135135
if ($message instanceof AMQPMessage) {
136136
return new RabbitMQJob($this->container, $this, $this->channel, $queue, $message);
137137
}
138-
139-
return null;
140138
}
141139

142140
/**
@@ -159,6 +157,7 @@ private function getChannel()
159157

160158
/**
161159
* @param $name
160+
*
162161
* @return array
163162
*/
164163
private function declareQueue($name)
@@ -195,7 +194,7 @@ private function declareQueue($name)
195194
}
196195

197196
/**
198-
* @param string $destination
197+
* @param string $destination
199198
* @param DateTime|int $delay
200199
*
201200
* @return string
@@ -205,7 +204,7 @@ private function declareDelayedQueue($destination, $delay)
205204
$delay = $this->getSeconds($delay);
206205
$destination = $this->getQueueName($destination);
207206
$destinationExchange = $this->configExchange['name'] ?: $destination;
208-
$name = $this->getQueueName($destination) . '_deferred_' . $delay;
207+
$name = $this->getQueueName($destination).'_deferred_'.$delay;
209208
$exchange = $this->configExchange['name'] ?: $destination;
210209

211210
// declare exchange
@@ -226,9 +225,9 @@ private function declareDelayedQueue($destination, $delay)
226225
$this->configQueue['auto_delete'],
227226
false,
228227
new AMQPTable([
229-
'x-dead-letter-exchange' => $destinationExchange,
228+
'x-dead-letter-exchange' => $destinationExchange,
230229
'x-dead-letter-routing-key' => $destination,
231-
'x-message-ttl' => $delay * 1000,
230+
'x-message-ttl' => $delay * 1000,
232231
])
233232
);
234233

@@ -239,7 +238,7 @@ private function declareDelayedQueue($destination, $delay)
239238
}
240239

241240
/**
242-
* Sets the attempts member variable to be used in message generation
241+
* Sets the attempts member variable to be used in message generation.
243242
*
244243
* @param int $count
245244
*
@@ -249,4 +248,4 @@ public function setAttempts($count)
249248
{
250249
$this->attempts = $count;
251250
}
252-
}
251+
}

src/config/rabbitmq.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<?php
22

33
/**
4-
* default configuration for laravel-queue-rabbitmq merged with project config to base key 'queue'
4+
* default configuration for laravel-queue-rabbitmq merged with project config to base key 'queue'.
5+
*
56
* @see \MapleSyrupGroup\AMQPEvents\Providers\AMQPEventServiceProvider
67
*/
78
return [
@@ -11,8 +12,8 @@
1112
'host' => env('RABBITMQ_HOST', '127.0.0.1'),
1213
'port' => env('RABBITMQ_PORT', 5672),
1314

14-
'vhost' => env('RABBITMQ_VHOST', '/'),
15-
'login' => env('RABBITMQ_LOGIN', 'guest'),
15+
'vhost' => env('RABBITMQ_VHOST', '/'),
16+
'login' => env('RABBITMQ_LOGIN', 'guest'),
1617
'password' => env('RABBITMQ_PASSWORD', 'guest'),
1718

1819
'queue' => env('RABBITMQ_QUEUE'),
@@ -24,9 +25,9 @@
2425
// create the queue if not exists and bind to the exchange
2526

2627
'queue_params' => [
27-
'passive' => env('RABBITMQ_QUEUE_PASSIVE', false),
28-
'durable' => env('RABBITMQ_QUEUE_DURABLE', true),
29-
'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),
3031
'auto_delete' => env('RABBITMQ_QUEUE_AUTODELETE', false),
3132
],
3233
'exchange_params' => [
@@ -39,4 +40,4 @@
3940
'auto_delete' => env('RABBITMQ_EXCHANGE_AUTODELETE', false),
4041
],
4142

42-
];
43+
];

src/examples/app.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
VladimirYuldashev\LaravelQueueRabbitMQ\LaravelQueueRabbitMQServiceProvider::class,
77
]),
88

9-
];
9+
];

src/examples/queue.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,38 +37,38 @@
3737

3838
'database' => [
3939
'driver' => 'database',
40-
'table' => 'jobs',
41-
'queue' => 'default',
40+
'table' => 'jobs',
41+
'queue' => 'default',
4242
'expire' => 60,
4343
],
4444

4545
'beanstalkd' => [
4646
'driver' => 'beanstalkd',
47-
'host' => 'localhost',
48-
'queue' => 'default',
49-
'ttr' => 60,
47+
'host' => 'localhost',
48+
'queue' => 'default',
49+
'ttr' => 60,
5050
],
5151

5252
'sqs' => [
5353
'driver' => 'sqs',
54-
'key' => 'your-public-key',
54+
'key' => 'your-public-key',
5555
'secret' => 'your-secret-key',
56-
'queue' => 'your-queue-url',
56+
'queue' => 'your-queue-url',
5757
'region' => 'us-east-1',
5858
],
5959

6060
'iron' => [
61-
'driver' => 'iron',
62-
'host' => 'mq-aws-us-east-1.iron.io',
63-
'token' => 'your-token',
61+
'driver' => 'iron',
62+
'host' => 'mq-aws-us-east-1.iron.io',
63+
'token' => 'your-token',
6464
'project' => 'your-project-id',
65-
'queue' => 'your-queue-name',
65+
'queue' => 'your-queue-name',
6666
'encrypt' => true,
6767
],
6868

6969
'redis' => [
7070
'driver' => 'redis',
71-
'queue' => 'default',
71+
'queue' => 'default',
7272
'expire' => 60,
7373
],
7474

@@ -78,8 +78,8 @@
7878
'host' => env('RABBITMQ_HOST', '127.0.0.1'),
7979
'port' => env('RABBITMQ_PORT', 5672),
8080

81-
'vhost' => env('RABBITMQ_VHOST', '/'),
82-
'login' => env('RABBITMQ_LOGIN', 'guest'),
81+
'vhost' => env('RABBITMQ_VHOST', '/'),
82+
'login' => env('RABBITMQ_LOGIN', 'guest'),
8383
'password' => env('RABBITMQ_PASSWORD', 'guest'),
8484

8585
'queue' => env('RABBITMQ_QUEUE'),
@@ -90,9 +90,9 @@
9090
// create the queue if not exists and bind to the exchange
9191

9292
'queue_params' => [
93-
'passive' => env('RABBITMQ_QUEUE_PASSIVE', false),
94-
'durable' => env('RABBITMQ_QUEUE_DURABLE', true),
95-
'exclusive' => env('RABBITMQ_QUEUE_EXCLUSIVE', false),
93+
'passive' => env('RABBITMQ_QUEUE_PASSIVE', false),
94+
'durable' => env('RABBITMQ_QUEUE_DURABLE', true),
95+
'exclusive' => env('RABBITMQ_QUEUE_EXCLUSIVE', false),
9696
'auto_delete' => env('RABBITMQ_QUEUE_AUTODELETE', false),
9797
],
9898

@@ -123,7 +123,7 @@
123123

124124
'failed' => [
125125
'database' => 'mysql',
126-
'table' => 'failed_jobs',
126+
'table' => 'failed_jobs',
127127
],
128128

129129
];

0 commit comments

Comments
 (0)