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

ListDrivers   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 6 1
A handle() 0 14 2
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