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

RouteListCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 9
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 25
rs 10
c 9
b 0
f 0
wmc 3

3 Methods

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