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

Between::validateValue()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 4
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 6
ccs 0
cts 5
cp 0
crap 12
rs 10
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 Between implements FilterInterface
10
{
11
    private string $field;
12
13
    /**
14
     * @var bool|float|int|string
15
     */
16
    private $firstValue;
17
18
    /**
19
     * @var bool|float|int|string
20
     */
21
    private $secondValue;
22
23
    /**
24
     * @param string $field
25
     * @param bool|float|int|string $firstValue
26
     * @param bool|float|int|string $secondValue
27
     */
28 11
    public function __construct(string $field, $firstValue, $secondValue)
29
    {
30 11
        $this->field = $field;
31
32 11
        FilterDataValidationHelper::assertIsScalar($firstValue);
33 7
        FilterDataValidationHelper::assertIsScalar($secondValue);
34
35 3
        $this->firstValue = $firstValue;
36 3
        $this->secondValue = $secondValue;
37 3
    }
38
39 3
    public function toArray(): array
40
    {
41 3
        return [self::getOperator(), $this->field, $this->firstValue, $this->secondValue];
42
    }
43
44 84
    public static function getOperator(): string
45
    {
46 84
        return 'between';
47
    }
48
}
49