DebugRouterCommand::execute()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 8
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 15
rs 10
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
}