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

AnnotatedWithMatcher   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 5
c 1
b 0
f 1
lcom 1
cbo 2
dl 0
loc 34
ccs 11
cts 11
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A matchesClass() 0 7 2
A matchesMethod() 0 7 2
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\Matcher;
8
9
use Doctrine\Common\Annotations\AnnotationReader;
10
use Ray\Aop\AbstractMatcher;
11
12
class AnnotatedWithMatcher extends AbstractMatcher
13
{
14
    /**
15
     * @var AnnotationReader
16
     */
17
    private $reader;
18
19 5
    public function __construct()
20
    {
21 5
        $this->reader = new AnnotationReader();
22 5
    }
23
24
    /**
25
     * {@inheritdoc}
26
     */
27 2
    public function matchesClass(\ReflectionClass $class, array $arguments)
28
    {
29 2
        list($annotation) = $arguments;
30 2
        $annotation = $this->reader->getClassAnnotation($class, $annotation);
31
32 2
        return $annotation ? true : false;
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38 3
    public function matchesMethod(\ReflectionMethod $method, array $arguments)
39
    {
40 3
        list($annotation) = $arguments;
41 3
        $annotation = $this->reader->getMethodAnnotation($method, $annotation);
42
43 3
        return $annotation ? true : false;
44
    }
45
}
46