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

SubclassesOfMatcher::matchesClass()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 9.4285
cc 2
eloc 4
nc 2
nop 2
crap 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 Ray\Aop\AbstractMatcher;
10
use Ray\Aop\Exception\InvalidAnnotationException;
11
12
class SubclassesOfMatcher extends AbstractMatcher
13
{
14
    /**
15
     * {@inheritdoc}
16
     */
17 1
    public function matchesClass(\ReflectionClass $class, array $arguments)
18
    {
19 1
        list($superClass) = $arguments;
20 1
        $isSubClass = $class->isSubclassOf($superClass) || ($class->name === $superClass);
21
22 1
        return $isSubClass;
23
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28 1
    public function matchesMethod(\ReflectionMethod $method, array $arguments)
29
    {
30 1
        throw new InvalidAnnotationException('subclassesOf is only for class match');
31
    }
32
}
33