CompareHandler   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 17
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getAsWhereArguments() 0 6 1
A validateArguments() 0 4 2
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 8
    protected function validateArguments(array $arguments): void
16
    {
17 8
        if (count($arguments) !== 2) {
18 1
            throw new InvalidArgumentException('$arguments should contain exactly two elements.');
19
        }
20
    }
21
22 8
    public function getAsWhereArguments(array $arguments, array $handlers): array
23
    {
24 8
        $this->validateArguments($arguments);
25 7
        [$field, $value] = $arguments;
26
27 7
        return [$field, $this->getSymbol(), $value];
28
    }
29
}
30