Skip to content

Commit 759a404

Browse files
milkmeowoStyleCIBot
authored andcommitted
Apply fixes from StyleCI
1 parent ed96e9a commit 759a404

16 files changed

+313
-109
lines changed

src/Adaptors/MnsAdapter.php

Lines changed: 41 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
<?php
22

3+
/*
4+
* Laravel-Mns -- 阿里云消息队列(MNS)的 Laravel 适配。
5+
*
6+
* This file is part of the milkmeowo/laravel-mns.
7+
*
8+
* (c) Milkmeowo <milkmeowo@gmail.com>
9+
* @link: https://github.com/milkmeowo/laravel-queue-aliyun-mns
10+
*
11+
* This source file is subject to the MIT license that is bundled
12+
* with this source code in the file LICENSE.
13+
*/
14+
315
namespace Milkmeowo\LaravelMns\Adaptors;
416

517
use AliyunMNS\AsyncCallback;
@@ -27,7 +39,7 @@
2739
use AliyunMNS\Responses\SetQueueAttributeResponse;
2840

2941
/**
30-
* Class MNSAdapter
42+
* Class MNSAdapter.
3143
*
3244
* @method string getQueueName()
3345
* @method SetQueueAttributeResponse setAttribute(QueueAttributes $attributes)
@@ -61,22 +73,23 @@ class MnsAdapter
6173
*/
6274
const ADAPTER_TO_ALIYUN_MNS_SDK_VERSION = '1.3.5@2017-06-06';
6375
/**
64-
* Aliyun MNS Client
76+
* Aliyun MNS Client.
6577
*
66-
* @var MnsClient $client
78+
* @var MnsClient
6779
*/
6880
private $client;
6981
/**
7082
* Aliyun MNS SDK Queue.
7183
*
72-
* @var Queue $queue
84+
* @var Queue
7385
*/
7486
private $queue;
7587

7688
/**
7789
* MnsAdapter constructor.
90+
*
7891
* @param MnsClient $client
79-
* @param string $queue
92+
* @param string $queue
8093
*/
8194
public function __construct(MnsClient $client, string $queue)
8295
{
@@ -111,11 +124,12 @@ public function useQueue($queue)
111124
if (null != $queue) {
112125
$this->queue = $this->client->getQueueRef($queue);
113126
}
127+
114128
return $this;
115129
}
116130

117131
/**
118-
* 创建队列
132+
* 创建队列.
119133
*
120134
* @param string $queueName 队列名
121135
*/
@@ -124,16 +138,17 @@ public function createQueue($queueName)
124138
try {
125139
$request = new CreateQueueRequest($queueName);
126140
$response = $this->client->createQueue($request);
141+
127142
return $response->isSucceed();
128143
} catch (MnsException $e) {
129144
}
130145
}
131146

132147
/**
133-
* 异步创建队列
148+
* 异步创建队列.
134149
*
135-
* @param string $queueName 队列名
136-
* @param AsyncCallback|null $callback 异步回调
150+
* @param string $queueName 队列名
151+
* @param AsyncCallback|null $callback 异步回调
137152
*/
138153
public function createQueueAsync($queueName, AsyncCallback $callback = null)
139154
{
@@ -145,64 +160,66 @@ public function createQueueAsync($queueName, AsyncCallback $callback = null)
145160
}
146161

147162
/**
148-
* 获取队列列表
163+
* 获取队列列表.
149164
*
150165
* @param null $retNum 单次请求结果的最大返回个数,可以取1-1000范围内的整数值,默认值为1000。
151166
* @param null $prefix 按照该前缀开头的 queueName 进行查找。
152167
* @param null $marker 请求下一个分页的开始位置,一般从上次分页结果返回的NextMarker获取。
168+
*
153169
* @return \AliyunMNS\Responses\ListQueueResponse
154170
*/
155171
public function listQueue($retNum = null, $prefix = null, $marker = null)
156172
{
157173
try {
158174
$request = new ListQueueRequest($retNum, $prefix, $marker);
175+
159176
return $this->client->listQueue($request);
160177
} catch (MnsException $e) {
161-
162178
}
163179
}
164180

165181
/**
166-
* 获取队列列表
182+
* 获取队列列表.
183+
*
184+
* @param int $retNum 单次请求结果的最大返回个数,可以取1-1000范围内的整数值,默认值为1000。
185+
* @param string $prefix 按照该前缀开头的 queueName 进行查找。
186+
* @param string $marker 请求下一个分页的开始位置,一般从上次分页结果返回的NextMarker获取。
187+
* @param AsyncCallback|null $callback
167188
*
168-
* @param int $retNum 单次请求结果的最大返回个数,可以取1-1000范围内的整数值,默认值为1000。
169-
* @param string $prefix 按照该前缀开头的 queueName 进行查找。
170-
* @param string $marker 请求下一个分页的开始位置,一般从上次分页结果返回的NextMarker获取。
171-
* @param AsyncCallback|NULL $callback
172189
* @return mixed
173190
*/
174-
public function listQueueAsync($retNum = NULL, $prefix = NULL, $marker = NULL, AsyncCallback $callback = NULL)
191+
public function listQueueAsync($retNum = null, $prefix = null, $marker = null, AsyncCallback $callback = null)
175192
{
176193
try {
177194
$request = new ListQueueRequest($retNum, $prefix, $marker);
195+
178196
return $this->client->listQueueAsync($request, $callback);
179197
} catch (MnsException $e) {
180-
181198
}
182-
183199
}
184200

185201
/**
186-
* 删除队列
202+
* 删除队列.
187203
*
188204
* @param string $queueName 队列名
189205
*/
190206
public function deleteQueue($queueName)
191207
{
192208
try {
193209
$response = $this->client->deleteQueue($queueName);
210+
194211
return $response->isSucceed();
195212
} catch (MnsException $e) {
196213
}
197214
}
198215

199216
/**
200-
* 异步删除队列
217+
* 异步删除队列.
201218
*
202-
* @param string $queueName 队列名
203-
* @param AsyncCallback|NULL $callback
219+
* @param string $queueName 队列名
220+
* @param AsyncCallback|null $callback
204221
*/
205-
public function deleteQueueAsync($queueName, AsyncCallback $callback = NULL)
222+
public function deleteQueueAsync($queueName, AsyncCallback $callback = null)
206223
{
207224
try {
208225
$this->client->deleteQueueAsync($queueName, $callback);

src/Connectors/MnsConnector.php

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
<?php
22

3+
/*
4+
* Laravel-Mns -- 阿里云消息队列(MNS)的 Laravel 适配。
5+
*
6+
* This file is part of the milkmeowo/laravel-mns.
7+
*
8+
* (c) Milkmeowo <milkmeowo@gmail.com>
9+
* @link: https://github.com/milkmeowo/laravel-queue-aliyun-mns
10+
*
11+
* This source file is subject to the MIT license that is bundled
12+
* with this source code in the file LICENSE.
13+
*/
14+
315
namespace Milkmeowo\LaravelMns\Connectors;
416

517
use AliyunMNS\Client as MnsClient;
@@ -10,9 +22,10 @@
1022
class MnsConnector implements ConnectorInterface
1123
{
1224
/**
13-
* 接口方法,连接器
25+
* 接口方法,连接器.
1426
*
1527
* @param array $config
28+
*
1629
* @return \Illuminate\Contracts\Queue\Queue|MnsQueue
1730
*/
1831
public function connect(array $config)
@@ -23,23 +36,24 @@ public function connect(array $config)
2336
}
2437

2538
/**
26-
* Mns 适配器
39+
* Mns 适配器.
2740
*
2841
* @param array $config
42+
*
2943
* @return MnsAdapter
3044
*/
3145
public function getAdapter(array $config)
3246
{
3347
$client = $this->getClient($config);
3448

3549
return new MnsAdapter($client, $config['queue']);
36-
3750
}
3851

3952
/**
40-
* Mns Client
53+
* Mns Client.
4154
*
4255
* @param array $config
56+
*
4357
* @return MnsClient
4458
*/
4559
public function getClient(array $config)

src/Console/MnsCreateQueueCommand.php

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

3-
namespace Milkmeowo\LaravelMns\Console;
3+
/*
4+
* Laravel-Mns -- 阿里云消息队列(MNS)的 Laravel 适配。
5+
*
6+
* This file is part of the milkmeowo/laravel-mns.
7+
*
8+
* (c) Milkmeowo <milkmeowo@gmail.com>
9+
* @link: https://github.com/milkmeowo/laravel-queue-aliyun-mns
10+
*
11+
* This source file is subject to the MIT license that is bundled
12+
* with this source code in the file LICENSE.
13+
*/
414

15+
namespace Milkmeowo\LaravelMns\Console;
516

617
use AliyunMNS\Client;
718
use AliyunMNS\Exception\MnsException;
@@ -36,14 +47,15 @@ public function handle()
3647
if (!$queue) {
3748
$queue = $this->ask('请输入队列名称');
3849
}
50+
3951
try {
4052
$client = new Client($config['endpoint'], $config['key'], $config['secret']);
4153
$request = new CreateQueueRequest($queue);
4254
$client->createQueue($request);
4355
$this->info('队列创建成功');
4456
$this->alert($queue);
4557
} catch (MnsException $e) {
46-
$this->error('队列创建失败:' . $e);
58+
$this->error('队列创建失败:'.$e);
4759
}
4860
}
4961
}

src/Console/MnsDeleteQueueCommand.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
<?php
22

3+
/*
4+
* Laravel-Mns -- 阿里云消息队列(MNS)的 Laravel 适配。
5+
*
6+
* This file is part of the milkmeowo/laravel-mns.
7+
*
8+
* (c) Milkmeowo <milkmeowo@gmail.com>
9+
* @link: https://github.com/milkmeowo/laravel-queue-aliyun-mns
10+
*
11+
* This source file is subject to the MIT license that is bundled
12+
* with this source code in the file LICENSE.
13+
*/
14+
315
namespace Milkmeowo\LaravelMns\Console;
416

517
use AliyunMNS\Client;
@@ -34,13 +46,14 @@ public function handle()
3446
if (!$queue) {
3547
$queue = $this->ask('请输入队列名称');
3648
}
49+
3750
try {
3851
$client = new Client($config['endpoint'], $config['key'], $config['secret']);
3952
$client->deleteQueue($queue);
4053
$this->info('队列删除成功');
4154
$this->alert($queue);
4255
} catch (MnsException $e) {
43-
$this->error('队列删除失败:' . $e);
56+
$this->error('队列删除失败:'.$e);
4457
}
4558
}
4659
}

src/Console/MnsFlushCommand.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
<?php
22

3+
/*
4+
* Laravel-Mns -- 阿里云消息队列(MNS)的 Laravel 适配。
5+
*
6+
* This file is part of the milkmeowo/laravel-mns.
7+
*
8+
* (c) Milkmeowo <milkmeowo@gmail.com>
9+
* @link: https://github.com/milkmeowo/laravel-queue-aliyun-mns
10+
*
11+
* This source file is subject to the MIT license that is bundled
12+
* with this source code in the file LICENSE.
13+
*/
14+
315
namespace Milkmeowo\LaravelMns\Console;
416

517
use AliyunMNS\Client;
@@ -41,6 +53,7 @@ public function handle()
4153
$hasMessage = true;
4254
while ($hasMessage) {
4355
$this->info('拉取信息中...');
56+
4457
try {
4558
$response = $queue->batchPeekMessage(15);
4659
if ($response->getMessages()) {
@@ -55,15 +68,15 @@ public function handle()
5568
$response = $queue->batchReceiveMessage(new BatchReceiveMessageRequest(15, 30));
5669
$handles = [];
5770
/**
58-
* @var Message $message
71+
* @var Message
5972
*/
6073
foreach ($response->getMessages() as $message) {
6174
$handles[] = $message->getReceiptHandle();
6275
}
6376
$response = $queue->batchDeleteMessage($handles);
6477
if ($response->isSucceed()) {
6578
foreach ($handles as $handle) {
66-
$this->info(sprintf("信息: %s 删除成功", $handle));
79+
$this->info(sprintf('信息: %s 删除成功', $handle));
6780
}
6881
}
6982
}

0 commit comments

Comments
 (0)