Filter::__invoke()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 2
nc 3
nop 1
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 3
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace Zalas\Toolbox\Tool;
4
5
class Filter
6
{
7
    /**
8
     * @var string[]
9
     */
10
    private array $excludedTags;
11
12
    /**
13
     * @var string[]
14
     */
15
    private array $tags;
16
17
    /**
18
     * @param string[] $excludedTags
19
     * @param string[] $tags
20
     */
21 42
    public function __construct(array $excludedTags, array $tags)
22
    {
23 42
        $this->excludedTags = $excludedTags;
24 42
        $this->tags = $tags;
25
    }
26
27 16
    public function __invoke(Tool $tool): bool
28
    {
29 16
        return $this->excludedTags === \array_diff($this->excludedTags, $tool->tags())
30 16
            && (empty($this->tags) || \array_intersect($this->tags, $tool->tags()));
31
    }
32
}
33