Passed
Pull Request — master (#38)
by Rustam
02:23
created

ClassImplements   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 17
ccs 7
cts 7
cp 1
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A match() 0 8 3
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Classifier\Filter;
6
7
use ReflectionClass;
8
9
final class ClassImplements implements FilterInterface
10
{
11
    private array $interfaces;
12
13 22
    public function __construct(string ...$interfaces)
14
    {
15 22
        $this->interfaces = $interfaces;
16
    }
17
18 22
    public function match(ReflectionClass $reflectionClass): bool
19
    {
20 22
        if (empty($this->interfaces) || $reflectionClass->isInterface()) {
21 10
            return false;
22
        }
23 20
        $interfaces = $reflectionClass->getInterfaceNames();
24
25 20
        return count(array_intersect($this->interfaces, $interfaces)) === count($this->interfaces);
26
    }
27
}
28