Completed
Push — param-inject ( 5f90ee...b7e6e7 )
by Akihito
01:14
created

AssistedInjectMatcher::matchesMethod()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.8333
c 0
b 0
f 0
cc 3
nc 3
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Ray\Di\Matcher;
6
7
use LogicException;
8
use Ray\Aop\AbstractMatcher;
9
use Ray\Di\Di\Inject;
10
use ReflectionAttribute;
11
use ReflectionClass;
12
use ReflectionMethod;
13
14
final class AssistedInjectMatcher extends AbstractMatcher
15
{
16
    /**
17
     * {@inheritdoc}
18
     *
19
     * @codeCoverageIgnore
20
     */
21
    public function matchesClass(ReflectionClass $class, array $arguments): bool
22
    {
23
        throw new LogicException('Should not used in class matcher');
24
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function matchesMethod(ReflectionMethod $method, array $arguments): bool
30
    {
31
        $params = $method->getParameters();
32
        foreach ($params as $param) {
33
            /** @var list<ReflectionAttribute> $attributes */
0 ignored issues
show
Documentation introduced by
The doc-type list<ReflectionAttribute> could not be parsed: Expected "|" or "end of type", but got "<" at position 4. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
34
            $attributes = $param->getAttributes(Inject::class);
35
            if (isset($attributes[0])) {
36
                return true;
37
            }
38
        }
39
40
        return false;
41
    }
42
}
43