StartsWithMatcher   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 2
eloc 4
c 1
b 1
f 0
dl 0
loc 22
ccs 6
cts 6
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A matchesMethod() 0 6 1
A matchesClass() 0 6 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