AnnotatedWithMatcher::matchesMethod()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 2
Bugs 1 Features 0
Metric Value
cc 1
eloc 4
c 2
b 1
f 0
nc 1
nop 2
dl 0
loc 9
ccs 3
cts 3
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Ray\Aop\Matcher;
6
7
use Ray\Aop\AbstractMatcher;
8
use ReflectionClass;
9
use ReflectionMethod;
10
11
use function assert;
12
13
final class AnnotatedWithMatcher extends AbstractMatcher
14
{
15
    /**
16
     * {@inheritDoc}
17
     */
18
    public function matchesClass(ReflectionClass $class, array $arguments): bool
19
    {
20
        assert($class instanceof \Ray\Aop\ReflectionClass);
21 5
        /** @var array<class-string> $arguments */
22
        [$annotation] = $arguments;
23 5
        /** @psalm-suppress MixedAssignment $annotation */
24 5
        $annotation = $class->getAnnotation($annotation);
25 5
26
        return (bool) $annotation;
27
    }
28
29
    /**
30 2
     * {@inheritDoc}
31
     */
32 2
    public function matchesMethod(ReflectionMethod $method, array $arguments): bool
33 2
    {
34
        assert($method instanceof \Ray\Aop\ReflectionMethod);
35 2
        /** @var array<class-string> $arguments */
36
        [$annotation] = $arguments;
37
38
        $annotation = $method->getAnnotation($annotation);
39
40
        return (bool) $annotation;
41 3
    }
42
}
43