MappingFilter::isAccept()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 7
nc 3
nop 1
dl 0
loc 14
ccs 8
cts 8
cp 1
crap 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Darkilliant\ProcessBundle\Filter;
6
7
use Darkilliant\ProcessBundle\Registry\FilterRegistry;
8
9
class MappingFilter
10
{
11
    /** @var FilterRegistry */
12
    private $registry;
13
14 2
    public function __construct(FilterRegistry $registry)
15
    {
16 2
        $this->registry = $registry;
17 2
    }
18
19 2
    public function isAccept(array $filters)
20
    {
21 2
        foreach ($filters as $filterConfig) {
22 2
            $localAccept = $this->registry->get($filterConfig['type'])
23 2
                ->isAccept($filterConfig['value'], $filterConfig['options']);
24
25 2
            $validWhenReturn = $filterConfig['valid_when_return'] ?? true;
26
27 2
            if ($localAccept !== $validWhenReturn) {
28 2
                return false;
29
            }
30
        }
31
32 1
        return true;
33
    }
34
}
35