Completed
Push — master ( 2a88b7...1fad07 )
by Vladimir
06:33
created

ListDrivers::handle()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 14
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 10
nc 1
nop 0
dl 0
loc 14
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FondBot\Toolbelt\Commands;
6
7
use FondBot\Toolbelt\Command;
8
use Symfony\Component\Console\Helper\Table;
9
10
class ListDrivers extends Command
11
{
12
    protected function configure(): void
13
    {
14
        $this
15
            ->setName('driver:list')
16
            ->setDescription('Get list of all available drivers.');
17
    }
18
19
    public function handle(): void
20
    {
21
        $drivers = collect($this->kernel->getDrivers())
22
            ->map(function ($item) {
23
                return [$item['name'], $item['package'], $item['official'] ? '✅' : '❌'];
24
            })
25
            ->toArray();
26
27
        $table = new Table($this->output);
28
        $table
29
            ->setHeaders(['Name', 'Package', 'Official'])
30
            ->setRows($drivers)
31
            ->render();
32
    }
33
}
34