Filter   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 26
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __invoke() 0 4 3
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