Completed
Push — param-inject ( 83c5f6 )
by Akihito
01:11
created

ParamInjectMatcher::matchesClass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Ray\Di\Matcher;
6
7
use Ray\Aop\AbstractMatcher;
8
use Ray\Di\Di\Inject;
9
use ReflectionClass;
10
use ReflectionMethod;
11
12
final class ParamInjectMatcher extends AbstractMatcher
13
{
14
    /**
15
     * {@inheritdoc}
16
     */
17
    public function matchesClass(ReflectionClass $class, array $arguments): bool
18
    {
19
        return true;
20
    }
21
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function matchesMethod(ReflectionMethod $method, array $arguments): bool
26
    {
27
        $params = $method->getParameters();
28
        foreach ($params as $param) {
29
            $attributes = $param->getAttributes(Inject::class);
30
            if (isset($attributes[0])) {
31
                return true;
32
            }
33
        }
34
35
        return false;
36
    }
37
}
38