Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
RouteAttributeHandler
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
3 / 3
4
100.00% covered (success)
100.00%
1 / 1
 __construct
n/a
0 / 0
n/a
0 / 0
1
 attributeClass
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 targets
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 handle
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace Dynart\Micro\AttributeHandler;
4
5use Dynart\Micro\AttributeHandlerInterface;
6use Dynart\Micro\Attribute\Route;
7use Dynart\Micro\RouterInterface;
8
9/**
10 * Handles #[Route] attributes
11 *
12 * @see AttributeHandler
13 * @package Dynart\Micro
14 */
15class RouteAttributeHandler implements AttributeHandlerInterface {
16
17    public function __construct(private RouterInterface $router) {}
18
19    public function attributeClass(): string {
20        return Route::class;
21    }
22
23    public function targets(): array {
24        return [AttributeHandlerInterface::TARGET_METHOD];
25    }
26
27    public function handle(string $className, mixed $subject, object $attribute): void {
28        $this->router->add($attribute->path, [$className, $subject->getName()], $attribute->method);
29    }
30}