|
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
|
|
|
|