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

ListDrivers   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 24
ccs 0
cts 10
cp 0
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 18 3
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