Passed
Push — master ( 099506...a7575d )
by Evgeniy
02:33
created

In::toArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Data\Reader\Filter;
6
7
use Yiisoft\Data\Reader\FilterDataValidationHelper;
8
9
final class In implements FilterInterface
10
{
11
    private string $field;
12
    private array $value;
13
14
    /**
15
     * @param string $field
16
     * @param bool[]|float[]|int[]|string[] $value
17
     */
18 8
    public function __construct(string $field, array $value)
19
    {
20 8
        foreach ($value as $arrayValue) {
21 8
            FilterDataValidationHelper::assertIsScalar($arrayValue);
22
        }
23
24 4
        $this->field = $field;
25 4
        $this->value = $value;
26 4
    }
27
28 4
    public function toArray(): array
29
    {
30 4
        return [self::getOperator(), $this->field, $this->value];
31
    }
32
33 84
    public static function getOperator(): string
34
    {
35 84
        return 'in';
36
    }
37
}
38