Passed
Push — master ( 0bde90...425000 )
by Rustam
02:43
created

RequestResolver   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 9
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 4
c 1
b 0
f 0
dl 0
loc 9
ccs 4
cts 4
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A resolve() 0 7 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\RequestModel\Attribute;
6
7
use Psr\Http\Message\ServerRequestInterface;
8
9
final class RequestResolver implements HandlerParameterResolverInterface
10
{
11 3
    public function resolve(HandlerParameterAttributeInterface $attribute, ServerRequestInterface $request): mixed
12
    {
13 3
        if ($attribute::class !== Request::class) {
14 1
            throw new \InvalidArgumentException(sprintf('Expected "%s", got "%s".', Request::class, $attribute::class));
15
        }
16
17 2
        return $request->getAttribute($attribute->getName());
0 ignored issues
show
Bug introduced by
The method getName() does not exist on Yiisoft\RequestModel\Att...meterAttributeInterface. It seems like you code against a sub-type of said class. However, the method does not exist in Yiisoft\RequestModel\Attribute\UploadedFiles or Yiisoft\RequestModel\Tests\Support\MockAttribute. Are you sure you never get one of those? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

17
        return $request->getAttribute($attribute->/** @scrutinizer ignore-call */ getName());
Loading history...
18
    }
19
}
20