Completed
Push — master ( 6373f2...b930c3 )
by Dmitry
02:29
created

RegexAttribute::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
3
namespace hiapi\query\attributes;
4
5
/**
6
 * Class FloatAttribute
7
 *
8
 * @author Dmytro Naumenko <[email protected]>
9
 */
10
class RegexAttribute extends AbstractAttribute
11
{
12
    /**
13
     * @var string
14
     */
15
    protected $pattern;
16
17
    function __construct($pattern)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
18
    {
19
        $this->pattern = $pattern;
20
    }
21
22
    public function getOperatorRules()
23
    {
24
        $rule = ['match', 'pattern' => $this->pattern];
25
26
        return [
27
            'eq' => $rule,
28
            'ne' => $rule,
29
            'in' => ['each', 'rule' => $rule],
30
            'ni' => ['each', 'rule' => $rule],
31
            'like' => ['string'],
32
            'ilike' => ['string'],
33
        ];
34
    }
35
}
36