LogicalAndMatcher::matchesMethod()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3

Importance

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