Passed
Pull Request — master (#48)
by Alexander
15:11
created

CompareProcessor   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 6
c 1
b 0
f 0
dl 0
loc 14
rs 10

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\DataReader\Processor;
6
7
use Yiisoft\Data\Reader\Filter\FilterProcessorInterface;
8
9
abstract class CompareProcessor implements QueryBuilderProcessor, FilterProcessorInterface
10
{
11
    protected function validateArguments(array $arguments): void
12
    {
13
        if (count($arguments) !== 2) {
14
            throw new \InvalidArgumentException('$arguments should contain exactly two elements.');
15
        }
16
    }
17
    public function getAsWhereArguments(array $arguments, array $processors): array
18
    {
19
        $this->validateArguments($arguments);
20
        [$field, $value] = $arguments;
21
22
        return [$field, $this->getOperator(), $value];
23
    }
24
}
25