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

RegexAttribute   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 26
ccs 0
cts 9
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getOperatorRules() 0 13 1
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