Completed
Push — master ( 83b89e...48455b )
by Hannes
04:08 queued 02:15
created

OpenApiCompilerPass   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 19
rs 10
c 0
b 0
f 0
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A processRoute() 0 17 4
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace inroutephp\inroute\Compiler\OpenApi;
6
7
use inroutephp\inroute\Compiler\CompilerPassInterface;
8
use inroutephp\inroute\Runtime\RouteInterface;
9
use OpenApi\Annotations\Operation;
10
use const OpenApi\Annotations\UNDEFINED;
11
12
final class OpenApiCompilerPass implements CompilerPassInterface
13
{
14
    public function processRoute(RouteInterface $route): RouteInterface
15
    {
16
        if ($operation = $route->getAnnotation(Operation::CLASS)) {
0 ignored issues
show
Bug introduced by
The constant OpenApi\Annotations\Operation::CLASS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
17
            $route = $route
18
                ->withRoutable(true)
19
                ->withHttpMethod($operation->method);
20
21
            if ($operation->path != UNDEFINED) {
22
                $route = $route->withPath($operation->path);
23
            }
24
25
            if ($operation->operationId != UNDEFINED) {
26
                $route = $route->withName($operation->operationId);
27
            }
28
        }
29
30
        return $route;
31
    }
32
}
33