@@ -38,7 +38,6 @@ public function __construct(
38
38
* @param string $field
39
39
* @param Operator $operator
40
40
* @param mixed $value
41
- *
42
41
* @return Filter
43
42
*/
44
43
public static function create (string $ field , Operator $ operator , mixed $ value ): self
@@ -48,82 +47,82 @@ public static function create(string $field, Operator $operator, mixed $value):
48
47
49
48
/**
50
49
* @param array<string, scalar>|array<string> $filter
51
- * @return self
50
+ * @return Filter
52
51
*/
53
- public static function createFromArray (array $ filter ): self
52
+ public static function fromArray (array $ filter ): self
54
53
{
55
54
// check if the array is indexed or associative.
56
55
$ isIndexed = fn ($ source ): bool => ([] !== $ source ) && array_keys ($ source ) === range (0 , count ($ source ) - 1 );
57
56
58
57
return ($ isIndexed ($ filter ))
59
58
? self ::create (
60
59
"$ filter [0 ]" ,
61
- Operator::make ("$ filter [1 ]" ),
60
+ Operator::create ("$ filter [1 ]" ),
62
61
$ filter [2 ]
63
62
)
64
63
: self ::create (
65
64
"{$ filter ['field ' ]}" ,
66
- Operator::make ("{$ filter ['operator ' ]}" ),
65
+ Operator::create ("{$ filter ['operator ' ]}" ),
67
66
"{$ filter ['value ' ]}"
68
67
);
69
68
}
70
69
71
- public static function createEqual (string $ field , mixed $ value ): self
70
+ public static function equal (string $ field , mixed $ value ): self
72
71
{
73
72
return self ::create ($ field , Operator::EQUAL , $ value );
74
73
}
75
74
76
- public static function createNotEqual (string $ field , mixed $ value ): self
75
+ public static function notEqual (string $ field , mixed $ value ): self
77
76
{
78
77
return self ::create ($ field , Operator::NOT_LIKE , $ value );
79
78
}
80
79
81
- public static function createGreaterThan (string $ field , mixed $ value ): self
80
+ public static function greaterThan (string $ field , mixed $ value ): self
82
81
{
83
82
return self ::create ($ field , Operator::GT , $ value );
84
83
}
85
84
86
- public static function createGreaterOrEqualThan (string $ field , mixed $ value ): self
85
+ public static function greaterOrEqualThan (string $ field , mixed $ value ): self
87
86
{
88
87
return self ::create ($ field , Operator::GTE , $ value );
89
88
}
90
89
91
- public static function createLessThan (string $ field , mixed $ value ): self
90
+ public static function lessThan (string $ field , mixed $ value ): self
92
91
{
93
92
return self ::create ($ field , Operator::LT , $ value );
94
93
}
95
94
96
- public static function createLessOrEqualThan (string $ field , mixed $ value ): self
95
+ public static function lessOrEqualThan (string $ field , mixed $ value ): self
97
96
{
98
97
return self ::create ($ field , Operator::LTE , $ value );
99
98
}
100
99
101
- public static function createIn (string $ field , mixed $ value ): self
100
+ public static function in (string $ field , mixed $ value ): self
102
101
{
103
102
return self ::create ($ field , Operator::IN , $ value );
104
103
}
105
104
106
- public static function createNotIn (string $ field , mixed $ value ): self
105
+ public static function notIn (string $ field , mixed $ value ): self
107
106
{
108
107
return self ::create ($ field , Operator::NOT_IN , $ value );
109
108
}
110
109
111
- public static function createLike (string $ field , mixed $ value ): self
110
+ public static function like (string $ field , mixed $ value ): self
112
111
{
113
112
return self ::create ($ field , Operator::LIKE , $ value );
114
113
}
115
114
116
- public static function createNotLike (string $ field , mixed $ value ): self
115
+ public static function notLike (string $ field , mixed $ value ): self
117
116
{
118
117
return self ::create ($ field , Operator::NOT_LIKE , $ value );
119
118
}
120
119
121
- public static function createContains (string $ field , mixed $ value ): self
120
+ public static function contains (string $ field , mixed $ value ): self
122
121
{
123
122
return self ::create ($ field , Operator::CONTAINS , $ value );
124
123
}
125
124
126
- public static function createNotContains (string $ field , mixed $ value ): self
125
+ public static function notContains (string $ field , mixed $ value ): self
127
126
{
128
127
return self ::create ($ field , Operator::NOT_CONTAINS , $ value );
129
128
}
@@ -165,7 +164,7 @@ public function __toString(): string
165
164
$ this ->field (),
166
165
$ this ->operator ()->value ,
167
166
is_array ($ this ->value ())
168
- ? implode ('| ' , $ this ->value ())
167
+ ? implode (', ' , $ this ->value ())
169
168
: $ this ->value ()
170
169
);
171
170
}
0 commit comments