Completed
Push — master ( 06f997...84d5d5 )
by Vladimir
03:43
created

ListChannelsCommand::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 9
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FondBot\Console;
6
7
use Illuminate\Console\Command;
8
use FondBot\Channels\ChannelManager;
9
10
class ListChannelsCommand extends Command
11
{
12
    protected $signature = 'fondbot:channel:list';
13
    protected $description = 'List all registered channels';
14
15
    public function handle(ChannelManager $manager): void
16
    {
17
        $rows = collect($manager->all())
18
            ->transform(function ($item, $name) use ($manager) {
19
                return [$name, $manager->driver($item['driver'])->getName(), $manager->create($name)->getWebhookUrl()];
20
            })
21
            ->toArray();
22
23
        $this->table(['Name', 'Driver', 'Webhook URL'], $rows);
24
    }
25
}
26