SubclassesOfMatcher   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A matchesClass() 0 6 2
A matchesMethod() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Ray\Aop\Matcher;
6
7
use Ray\Aop\AbstractMatcher;
8
use Ray\Aop\Exception\InvalidAnnotationException;
9
use ReflectionClass;
10
use ReflectionMethod;
11
12
final class SubclassesOfMatcher extends AbstractMatcher
13
{
14
    /**
15
     * {@inheritdoc}
16
     */
17
    public function matchesClass(ReflectionClass $class, array $arguments): bool
18
    {
19 1
        /** @var array<class-string> $arguments */
20
        [$superClass] = $arguments;
21 1
22 1
        return $class->isSubclassOf($superClass) || ($class->name === $superClass);
23
    }
24 1
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function matchesMethod(ReflectionMethod $method, array $arguments): bool
29
    {
30 1
        unset($method, $arguments);
31
32 1
        throw new InvalidAnnotationException('subclassesOf is only for class match');
33
    }
34
}
35