PipeCompilerPass   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 16
rs 10
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A processRoute() 0 14 4
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace inroutephp\inroute\Compiler\Dsl;
6
7
use inroutephp\inroute\Annotations\Pipe;
8
use inroutephp\inroute\Compiler\CompilerPassInterface;
9
use inroutephp\inroute\Runtime\RouteInterface;
10
11
final class PipeCompilerPass implements CompilerPassInterface
12
{
13
    public function processRoute(RouteInterface $route): RouteInterface
14
    {
15
        /** @var Pipe $pipe */
16
        foreach ($route->getAnnotations(Pipe::CLASS) as $pipe) {
0 ignored issues
show
Bug introduced by
The constant inroutephp\inroute\Annotations\Pipe::CLASS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
17
            foreach ((array)$pipe->middlewares as $middleware) {
18
                $route = $route->withMiddleware($middleware);
19
            }
20
21
            foreach ((array)$pipe->attributes as $key => $value) {
22
                $route = $route->withAttribute($key, $value);
23
            }
24
        }
25
26
        return $route;
27
    }
28
}
29