Passed
Branch psalm-3 (d5d890)
by Wilmer
02:56
created

NotCondition   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 26
rs 10
c 0
b 0
f 0
wmc 4
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Db\Query\Conditions;
6
7
use Yiisoft\Db\Exception\InvalidArgumentException;
8
use Yiisoft\Db\Query\Conditions\Interface\NotConditionInterface;
0 ignored issues
show
Bug introduced by
A parse error occurred: Syntax error, unexpected T_INTERFACE, expecting T_STRING or '{' on line 8 at column 32
Loading history...
9
10
use function array_shift;
11
use function count;
12
13
/**
14
 * Condition that inverts passed {@see condition}.
15
 */
16
class NotCondition implements NotConditionInterface
17
{
18
    public function __construct(private mixed $condition)
19
    {
20
    }
21
22
    public function getCondition(): mixed
23
    {
24
        return $this->condition;
25
    }
26
27
    public static function fromArrayDefinition(string $operator, array $operands): self
28
    {
29
        if (count($operands) !== 1) {
30
            throw new InvalidArgumentException("Operator '$operator' requires exactly one operand.");
31
        }
32
33
        return new static(array_shift($operands));
34
    }
35
}
36