Passed
Pull Request — master (#48)
by Aleksei
11:05
created

CompareProcessor::validateArguments()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 2
nc 2
nop 1
1
<?php
2
3
namespace Yiisoft\Yii\Cycle\DataReader\Processor;
4
5
use Cycle\ORM\Select\QueryBuilder;
6
use Yiisoft\Data\Reader\Filter\FilterProcessorInterface;
7
8
abstract class CompareProcessor implements QueryBuilderProcessor, FilterProcessorInterface
9
{
10
    protected function validateArguments(array $arguments): void
11
    {
12
        if (count($arguments) !== 2) {
13
            throw new \InvalidArgumentException('$arguments should contain exactly two elements.');
14
        }
15
    }
16
    public function getAsWhereArguments(array $arguments, array $processors): array
17
    {
18
        $this->validateArguments($arguments);
19
        [$field, $value] = $arguments;
20
21
        return [$field, $this->getOperator(), $value];
22
    }
23
}
24