Completed
Push — master ( 816440...cac82f )
by Vladimir
12:37
created

ListDrivers::handle()   A

Complexity

Conditions 3
Paths 1

Size

Total Lines 18
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
cc 3
eloc 12
nc 1
nop 2
dl 0
loc 18
ccs 0
cts 10
cp 0
crap 12
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FondBot\Toolbelt;
6
7
use FondBot\Foundation\API;
8
use Illuminate\Console\Command;
9
use FondBot\Channels\ChannelManager;
10
11
class ListDrivers extends Command
12
{
13
    protected $signature = 'fondbot:driver-list';
14
    protected $description = 'Get list of installed drivers';
15
16
    public function handle(API $api, ChannelManager $manager): void
17
    {
18
        $installedDrivers = collect($manager->getDrivers())->keys()->toArray();
19
        $availableDrivers = $api->getDrivers();
20
21
        $rows = collect($availableDrivers)
22
            ->transform(function ($item) use ($installedDrivers) {
23
                return [
24
                    $item['name'],
25
                    $item['package'],
26
                    $item['official'] ? '✅' : '❌',
27
                    in_array($item['name'], $installedDrivers, true) ? '✅' : '❌',
28
                ];
29
            })
30
            ->toArray();
31
32
        $this->table(['Name', 'Package', 'Official', 'Installed'], $rows);
33
    }
34
}
35