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

In   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 9
c 0
b 0
f 0
dl 0
loc 27
ccs 10
cts 10
cp 1
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 3 1
A __construct() 0 8 2
A getOperator() 0 3 1
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