Passed
Push — master ( e54c12...dd8329 )
by Caen
03:56 queued 15s
created

RouteListCommand::makeHeader()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 2
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Hyde\Console\Commands;
6
7
use Hyde\Hyde;
8
use Hyde\Console\Concerns\Command;
9
use Hyde\Support\Internal\RouteListItem;
10
11
use function array_map;
12
use function array_keys;
13
use function array_values;
14
15
/**
16
 * Display the list of site routes.
17
 */
18
class RouteListCommand extends Command
19
{
20
    /** @var string */
21
    protected $signature = 'route:list';
22
23
    /** @var string */
24
    protected $description = 'Display all the registered routes';
25
26
    public function handle(): int
27
    {
28
        $routes = $this->generate();
29
30
        $this->table($this->makeHeader($routes), $routes);
31
32
        return Command::SUCCESS;
33
    }
34
35
    protected function generate(): array
36
    {
37
        return array_map([RouteListItem::class, 'format'], array_values(Hyde::routes()->all()));
38
    }
39
40
    protected function makeHeader(array $routes): array
41
    {
42
        return array_map([Hyde::class, 'makeTitle'], array_keys($routes[0]));
43
    }
44
}
45