AnnotatedWithMatcher::matchesMethod()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

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