1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace Yiisoft\RequestModel\Attribute; |
||
6 | |||
7 | use Psr\Http\Message\ServerRequestInterface; |
||
8 | use Yiisoft\Router\CurrentRoute; |
||
9 | |||
10 | final class RouteResolver implements HandlerParameterResolverInterface |
||
11 | { |
||
12 | 4 | public function __construct(private CurrentRoute $currentRoute) |
|
13 | { |
||
14 | 4 | } |
|
15 | |||
16 | 4 | public function resolve(HandlerParameterAttributeInterface $attribute, ServerRequestInterface $request): mixed |
|
17 | { |
||
18 | 4 | if ($attribute::class !== Route::class) { |
|
19 | 1 | throw new \InvalidArgumentException(sprintf('Expected "%s", got "%s".', Route::class, $attribute::class)); |
|
20 | } |
||
21 | |||
22 | 3 | return $this->currentRoute->getArgument($attribute->getName()) ?? throw new ValueNotFoundException(); |
|
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
23 | } |
||
24 | } |
||
25 |