ViolationFilterChain   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A __invoke() 0 9 3
1
<?php
2
/**
3
 * Copyright MediaCT. All rights reserved.
4
 * https://www.mediact.nl
5
 */
6
7
namespace Mediact\DependencyGuard\Violation\Filter;
8
9
use Mediact\DependencyGuard\Violation\ViolationInterface;
10
11
class ViolationFilterChain implements ViolationFilterInterface
12
{
13
    /** @var ViolationFilterInterface[] */
14
    private $filters;
15
16
    /**
17
     * Constructor.
18
     *
19
     * @param ViolationFilterInterface ...$filters
20
     */
21 9
    public function __construct(ViolationFilterInterface ...$filters)
22
    {
23 9
        $this->filters = $filters;
24 9
    }
25
26
    /**
27
     * Filter violations.
28
     *
29
     * @param ViolationInterface $violation
30
     *
31
     * @return bool
32
     */
33 9
    public function __invoke(ViolationInterface $violation): bool
34
    {
35 9
        foreach ($this->filters as $filter) {
36 8
            if (!$filter->__invoke($violation)) {
37 4
                return false;
38
            }
39
        }
40
41 5
        return true;
42
    }
43
}
44