DebugRouterCommand   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 21
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 0 15 2
1
<?php
2
3
namespace pjpawel\LightApi\Command\Internal;
4
5
use pjpawel\LightApi\Command\Input\InputInterface;
6
use pjpawel\LightApi\Command\Output\OutputInterface;
7
use pjpawel\LightApi\Route\Router;
8
use ReflectionClass;
9
10
class DebugRouterCommand extends KernelAwareCommand
11
{
12
13
    /**
14
     * @inheritDoc
15
     */
16
    public function execute(InputInterface $input, OutputInterface $output): int
17
    {
18
        $reflectionKernel = new ReflectionClass($this->kernel);
19
        $routerReflection = $reflectionKernel->getProperty('router');
20
        /** @var Router $router */
21
        $router = $routerReflection->getValue($this->kernel);
22
23
        $names = [];
24
        foreach ($router->routes as $route) {
25
            $names[] = $route->path;
26
        }
27
28
        $output->writeln($names);
29
30
        return self::SUCCESS;
31
    }
32
}