StartsWithMatcher::matchesMethod()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 2
c 1
b 1
f 0
dl 0
loc 6
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Ray\Aop\Matcher;
6
7
use Ray\Aop\AbstractMatcher;
8
use ReflectionClass;
9
use ReflectionMethod;
10
11
use function strpos;
12
13
final class StartsWithMatcher extends AbstractMatcher
14
{
15
    /**
16
     * {@inheritdoc}
17
     */
18 5
    public function matchesClass(ReflectionClass $class, array $arguments): bool
19
    {
20 5
        /** @var array<string> $arguments */
21
        [$startsWith] = $arguments;
22 5
23
        return strpos($class->name, $startsWith) === 0;
24
    }
25
26
    /**
27
     * {@inheritdoc}
28 32
     */
29
    public function matchesMethod(ReflectionMethod $method, array $arguments): bool
30 32
    {
31
        /** @var array<string> $arguments */
32 32
        [$startsWith] = $arguments;
33
34
        return strpos($method->name, $startsWith) === 0;
35
    }
36
}
37