LogicalOrMatcher   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 12
c 0
b 0
f 0
dl 0
loc 32
ccs 12
cts 12
cp 1
rs 10
wmc 6

2 Methods

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