Passed
Push — master ( 6137ca...01151b )
by Kevin
02:21
created

Spec::like()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 2
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace Zenstruck\Porpaginas;
4
5
use Zenstruck\Porpaginas\Specification\Filter\Equal;
6
use Zenstruck\Porpaginas\Specification\Filter\GreaterThan;
7
use Zenstruck\Porpaginas\Specification\Filter\GreaterThanOrEqual;
8
use Zenstruck\Porpaginas\Specification\Filter\In;
9
use Zenstruck\Porpaginas\Specification\Filter\IsNotNull;
10
use Zenstruck\Porpaginas\Specification\Filter\IsNull;
11
use Zenstruck\Porpaginas\Specification\Filter\LessThan;
12
use Zenstruck\Porpaginas\Specification\Filter\LessThanOrEqual;
13
use Zenstruck\Porpaginas\Specification\Filter\Like;
14
use Zenstruck\Porpaginas\Specification\Filter\NotEqual;
15
use Zenstruck\Porpaginas\Specification\Filter\NotIn;
16
use Zenstruck\Porpaginas\Specification\Filter\NotLike;
17
use Zenstruck\Porpaginas\Specification\Logic\AndX;
18
use Zenstruck\Porpaginas\Specification\Logic\OrX;
19
use Zenstruck\Porpaginas\Specification\OrderBy;
20
21
/**
22
 * @author Kevin Bond <[email protected]>
23
 */
24
final class Spec
25
{
26 4
    public static function andX(...$children): AndX
27
    {
28 4
        return new AndX(...$children);
29
    }
30
31 2
    public static function orX(...$children): OrX
32
    {
33 2
        return new OrX(...$children);
34
    }
35
36 4
    public static function like(string $field, $value): Like
37
    {
38 4
        return new Like($field, $value);
39
    }
40
41 4
    public static function notLike(string $field, $value): NotLike
42
    {
43 4
        return new NotLike($field, $value);
44
    }
45
46 2
    public static function contains(string $field, $value): Like
47
    {
48 2
        return Like::contains($field, $value);
49
    }
50
51 2
    public static function notContains(string $field, $value): NotLike
52
    {
53 2
        return NotLike::contains($field, $value);
54
    }
55
56 2
    public static function beginsWith(string $field, $value): Like
57
    {
58 2
        return Like::beginsWith($field, $value);
59
    }
60
61 2
    public static function notBeginningWith(string $field, $value): NotLike
62
    {
63 2
        return NotLike::beginsWith($field, $value);
64
    }
65
66 2
    public static function endsWith(string $field, $value): Like
67
    {
68 2
        return Like::endsWith($field, $value);
69
    }
70
71 2
    public static function notEndingWith(string $field, $value): NotLike
72
    {
73 2
        return NotLike::endsWith($field, $value);
74
    }
75
76 6
    public static function eq(string $field, $value): Equal
77
    {
78 6
        return new Equal($field, $value);
79
    }
80
81 2
    public static function neq(string $field, $value): NotEqual
82
    {
83 2
        return new NotEqual($field, $value);
84
    }
85
86 2
    public static function isNull(string $field): IsNull
87
    {
88 2
        return new IsNull($field);
89
    }
90
91 2
    public static function isNotNull(string $field): IsNotNull
92
    {
93 2
        return new IsNotNull($field);
94
    }
95
96 10
    public static function in(string $field, array $value): In
97
    {
98 10
        return new In($field, $value);
99
    }
100
101 10
    public static function notIn(string $field, array $value): NotIn
102
    {
103 10
        return new NotIn($field, $value);
104
    }
105
106 6
    public static function lt(string $field, $value): LessThan
107
    {
108 6
        return new LessThan($field, $value);
109
    }
110
111 2
    public static function lte(string $field, $value): LessThanOrEqual
112
    {
113 2
        return new LessThanOrEqual($field, $value);
114
    }
115
116 8
    public static function gt(string $field, $value): GreaterThan
117
    {
118 8
        return new GreaterThan($field, $value);
119
    }
120
121 2
    public static function gte(string $field, $value): GreaterThanOrEqual
122
    {
123 2
        return new GreaterThanOrEqual($field, $value);
124
    }
125
126 2
    public static function sortAsc(string $field): OrderBy
127
    {
128 2
        return OrderBy::asc($field);
129
    }
130
131 4
    public static function sortDesc(string $field): OrderBy
132
    {
133 4
        return OrderBy::desc($field);
134
    }
135
}
136