Passed
Push — master ( cd5f33...085ce3 )
by Aleksei
02:37
created

CompareHandler::validateArguments()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 2
c 0
b 0
f 0
nc 2
nop 1
dl 0
loc 4
ccs 0
cts 3
cp 0
crap 6
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\Cycle\Data\Reader\FilterHandler;
6
7
use InvalidArgumentException;
8
use Yiisoft\Data\Reader\FilterHandlerInterface;
9
use Yiisoft\Yii\Cycle\Data\Reader\QueryBuilderFilterHandler;
10
11
abstract class CompareHandler implements QueryBuilderFilterHandler, FilterHandlerInterface
12
{
13
    abstract protected function getSymbol(): string;
14
15
    protected function validateArguments(array $arguments): void
16
    {
17
        if (count($arguments) !== 2) {
18
            throw new InvalidArgumentException('$arguments should contain exactly two elements.');
19
        }
20
    }
21
22
    public function getAsWhereArguments(array $arguments, array $handlers): array
23
    {
24
        $this->validateArguments($arguments);
25
        [$field, $value] = $arguments;
26
27
        return [$field, $this->getSymbol(), $value];
28
    }
29
}
30