LogicalAndMatcher   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

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