Passed
Push — master ( 1f27ac...52075a )
by Alexander
04:53 queued 02:24
created

Like   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 3
c 0
b 0
f 0
dl 0
loc 18
ccs 6
cts 6
cp 1
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getOperator() 0 3 1
A toCriteriaArray() 0 3 1
A __construct() 0 2 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Data\Reader\Filter;
6
7
use Yiisoft\Data\Reader\FilterInterface;
8
9
/**
10
 * `Like` filter defines a criteria for ensuring field value is like-match to a given value.
11
 */
12
final class Like implements FilterInterface
13
{
14
    /**
15
     * @param string $field Name of the field to compare.
16
     * @param string $value Value to like-compare with.
17
     */
18 5
    public function __construct(private string $field, private string $value)
19
    {
20 5
    }
21
22 5
    public function toCriteriaArray(): array
23
    {
24 5
        return [self::getOperator(), $this->field, $this->value];
25
    }
26
27 106
    public static function getOperator(): string
28
    {
29 106
        return 'like';
30
    }
31
}
32