Matcher   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 11
c 0
b 0
f 0
dl 0
loc 68
ccs 17
cts 17
cp 1
rs 10
wmc 9

7 Methods

Rating   Name   Duplication   Size   Complexity  
A subclassesOf() 0 7 2
A logicalNot() 0 3 1
A any() 0 3 1
A logicalAnd() 0 3 1
A logicalOr() 0 3 1
A startsWith() 0 3 1
A annotatedWith() 0 7 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Ray\Aop;
6
7
use Ray\Aop\Exception\InvalidAnnotationException;
8
use Ray\Aop\Exception\InvalidArgumentException;
9
10
use function class_exists;
11
12
class Matcher implements MatcherInterface
13
{
14
    /**
15
     * {@inheritDoc}
16
     */
17
    public function any()
18
    {
19 29
        return new BuiltinMatcher(__FUNCTION__, []);
20
    }
21 29
22
    /**
23
     * {@inheritDoc}
24
     */
25
    public function annotatedWith($annotationName): AbstractMatcher
26
    {
27 4
        if (! class_exists($annotationName)) {
28
            throw new InvalidAnnotationException($annotationName);
29 4
        }
30 1
31
        return new AnnotatedMatcher(__FUNCTION__, [$annotationName]);
32
    }
33 3
34
    /**
35
     * {@inheritDoc}
36
     */
37
    public function subclassesOf($superClass): AbstractMatcher
38
    {
39 2
        if (! class_exists($superClass)) {
40
            throw new InvalidArgumentException($superClass);
41 2
        }
42 1
43
        return new BuiltinMatcher(__FUNCTION__, [$superClass]);
44
    }
45 1
46
    /**
47
     * {@inheritDoc}
48
     */
49
    public function startsWith($prefix): AbstractMatcher
50
    {
51 30
        return new BuiltinMatcher(__FUNCTION__, [$prefix]);
52
    }
53 30
54
    // @codingStandardsIgnoreStart
55
56
    /**
57
     * {@inheritdoc}
58
     */
59
    public function logicalOr(AbstractMatcher $matcherA, AbstractMatcher $matcherB) : AbstractMatcher
60
    {
61 1
        return new BuiltinMatcher(__FUNCTION__, func_get_args());
62
    }
63 1
64
    /**
65
     * {@inheritdoc}
66
     */
67
    public function logicalAnd(AbstractMatcher $matcherA, AbstractMatcher $matcherB) : AbstractMatcher
68
    {
69 1
        return new BuiltinMatcher(__FUNCTION__, func_get_args());
70
    }
71 1
72
    // @codingStandardsIgnoreEnd
73
74
    /**
75
     * {@inheritDoc}
76
     */
77
    public function logicalNot(AbstractMatcher $matcher): AbstractMatcher
78
    {
79 1
        return new BuiltinMatcher(__FUNCTION__, [$matcher]);
80
    }
81
}
82