Completed
Branch 2.x (867c01)
by Akihito
09:30
created

Matcher   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 7
Bugs 1 Features 1
Metric Value
wmc 10
c 7
b 1
f 1
lcom 0
cbo 4
dl 0
loc 70
ccs 20
cts 20
cp 1
rs 10

7 Methods

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