AnnotatedWithMatcher   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A matchesMethod() 0 9 1
A matchesClass() 0 9 1
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