RoutePass::process()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 10
cc 2
nc 2
nop 1
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Thunder micro CLI framework.
7
 * (c) Jérémy Marodon <[email protected]>
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace RxThunder\Core\Router;
13
14
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\DependencyInjection\Reference;
17
18
class RoutePass implements CompilerPassInterface
19
{
20 3
    public function process(ContainerBuilder $container): void
21
    {
22 3
        $router_definition = $container->getDefinition(Router::class);
23
24
        /** @psalm-var array<class-string, array<string, string>> $routes */
25 3
        $routes = $container->findTaggedServiceIds('route');
26 3
        foreach ($routes as $service_id => $tag_attributes) {
27 1
            $router_definition->addMethodCall('addRoute', [new Reference($service_id)]);
28
        }
29 3
    }
30
}
31