Test Failed
Pull Request — master (#203)
by Sergei
13:15
created

RouteArgumentResolver::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 0
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Router\HydratorAttribute;
6
7
use Yiisoft\Hydrator\Context;
0 ignored issues
show
Bug introduced by
The type Yiisoft\Hydrator\Context was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Yiisoft\Hydrator\ParameterAttributeInterface;
0 ignored issues
show
Bug introduced by
The type Yiisoft\Hydrator\ParameterAttributeInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use Yiisoft\Hydrator\ParameterAttributeResolverInterface;
0 ignored issues
show
Bug introduced by
The type Yiisoft\Hydrator\Paramet...ributeResolverInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use Yiisoft\Hydrator\Result;
11
use Yiisoft\Hydrator\UnexpectedAttributeException;
0 ignored issues
show
Bug introduced by
The type Yiisoft\Hydrator\UnexpectedAttributeException was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use Yiisoft\Router\CurrentRoute;
13
14
final class RouteArgumentResolver implements ParameterAttributeResolverInterface
15
{
16
    public function __construct(
17
        private CurrentRoute $currentRoute,
18
    ) {
19
    }
20
21
    public function getParameterValue(ParameterAttributeInterface $attribute, Context $context): Result
22
    {
23
        if (!$attribute instanceof RouteArgument) {
24
            throw new UnexpectedAttributeException(RouteArgument::class, $attribute);
25
        }
26
27
        $arguments = $this->currentRoute->getArguments();
28
29
        $name = $attribute->getName() ?? $context->getParameter()->getName();
30
31
        if (array_key_exists($name, $arguments)) {
32
            return Result::success($arguments[$name]);
33
        }
34
35
        return Result::fail();
36
    }
37
}
38