FilterConditionTrait::checkCondition()   A
last analyzed

Complexity

Conditions 4
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 5
cts 5
cp 1
rs 9.2
c 0
b 0
f 0
cc 4
eloc 5
nc 2
nop 5
crap 4
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Rs\XmlFilter\Filter\Behavior;
6
7
use Rs\XmlFilter\Document\Element;
8
use Rs\XmlFilter\Filter\Manager\FilterManager;
9
10
trait FilterConditionTrait
11
{
12 31
    protected function checkCondition($key, $value, $options, Element $element, FilterManager $filterManager = null) : bool
13
    {
14 31
        if (is_callable($options['condition']) ||
15 31
            (is_string($options['condition']) && function_exists($options['condition']))
16
        ) {
17 6
            return (bool) $options['condition']($key, $value, $element, $filterManager);
18
        }
19
20 29
        return !$options['condition'];
21
    }
22
}
23