LogicalOrMatcher::matchesMethod()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 6
c 0
b 0
f 0
nc 3
nop 2
dl 0
loc 11
ccs 6
cts 6
cp 1
crap 3
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 LogicalOrMatcher extends AbstractMatcher
14
{
15
    /**
16
     * {@inheritDoc}
17
     */
18 4
    public function matchesClass(ReflectionClass $class, array $arguments): bool
19
    {
20 4
        foreach ($arguments as $matcher) {
21
            assert($matcher instanceof AbstractMatcher);
22 4
            $isMatch = $matcher->matchesClass($class, $matcher->getArguments());
23 4
            if ($isMatch === true) {
24 4
                return true;
25
            }
26
        }
27
28 1
        return false;
29
    }
30
31
    /**
32
     * {@inheritDoc}
33
     */
34 3
    public function matchesMethod(ReflectionMethod $method, array $arguments): bool
35
    {
36 3
        foreach ($arguments as $matcher) {
37
            assert($matcher instanceof AbstractMatcher);
38 3
            $isMatch = $matcher->matchesMethod($method, $matcher->getArguments());
39 3
            if ($isMatch === true) {
40 3
                return true;
41
            }
42
        }
43
44 1
        return false;
45
    }
46
}
47