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

In::validateValue()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 4.128

Importance

Changes 0
Metric Value
cc 4
eloc 4
nc 4
nop 1
dl 0
loc 6
ccs 4
cts 5
cp 0.8
crap 4.128
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A In::toArray() 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