NotInExpression   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 62.5%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 8
c 1
b 0
f 1
dl 0
loc 16
ccs 5
cts 8
cp 0.625
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A evaluate() 0 14 3
1
<?php declare(strict_types=1);
2
3
/**
4
 * @license     http://opensource.org/licenses/mit-license.php MIT
5
 * @link        https://github.com/nicoSWD
6
 * @author      Nicolas Oelgart <[email protected]>
7
 */
8
namespace nicoSWD\Rule\Expression;
9
10
use nicoSWD\Rule\TokenStream\TokenCollection;
11
use nicoSWD\Rule\Parser\Exception\ParserException;
12
13
final class NotInExpression extends BaseExpression
14
{
15 2
    public function evaluate(mixed $leftValue, mixed $rightValue): bool
16
    {
17 2
        if ($rightValue instanceof TokenCollection) {
18 2
            $rightValue = $rightValue->toArray();
19
        }
20
21 2
        if (!is_array($rightValue)) {
22
            throw new ParserException(sprintf(
23
                'Expected array, got "%s"',
24
                gettype($rightValue)
25
            ));
26
        }
27
28 2
        return !in_array($leftValue, $rightValue, strict: true);
29
    }
30
}
31