Total Complexity | 3 |
Total Lines | 36 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
21 | class MnsDeleteQueueCommand extends Command |
||
22 | { |
||
23 | /** |
||
24 | * The name and signature of the console command. |
||
25 | * |
||
26 | * @var string |
||
27 | */ |
||
28 | protected $signature = 'queue:mns:delete {queue?} {--c|connection=mns}'; |
||
29 | /** |
||
30 | * The console command description. |
||
31 | * |
||
32 | * @var string |
||
33 | */ |
||
34 | protected $description = '删除 MNS Queue'; |
||
35 | |||
36 | /** |
||
37 | * Execute the console command. |
||
38 | * |
||
39 | * @return void |
||
40 | */ |
||
41 | public function handle() |
||
42 | { |
||
43 | $queue = $this->argument('queue'); |
||
44 | $connection = $this->option('connection'); |
||
45 | $config = config("queue.connections.{$connection}"); |
||
46 | if (!$queue) { |
||
47 | $queue = $this->ask('请输入队列名称'); |
||
48 | } |
||
49 | |||
50 | try { |
||
51 | $client = new Client($config['endpoint'], $config['key'], $config['secret']); |
||
52 | $client->deleteQueue($queue); |
||
53 | $this->info('队列删除成功'); |
||
54 | $this->alert($queue); |
||
55 | } catch (MnsException $e) { |
||
56 | $this->error('队列删除失败:' . $e); |
||
57 | } |
||
60 |