@@ -22,12 +22,12 @@ final class Filter implements ValueObject
22
22
*
23
23
* @param string $field
24
24
* @param Operator $operator
25
- * @param mixed $value
25
+ * @param scalar|null|array<scalar> $value
26
26
*/
27
27
public function __construct (
28
28
private readonly string $ field ,
29
29
private readonly Operator $ operator ,
30
- private readonly mixed $ value ,
30
+ private readonly bool | float | int | string | null | array $ value ,
31
31
) {
32
32
$ this ->check ();
33
33
}
@@ -37,10 +37,10 @@ public function __construct(
37
37
*
38
38
* @param string $field
39
39
* @param Operator $operator
40
- * @param mixed $value
40
+ * @param scalar|null|array<scalar> $value
41
41
* @return Filter
42
42
*/
43
- public static function create (string $ field , Operator $ operator , mixed $ value ): self
43
+ public static function create (string $ field , Operator $ operator , bool | float | int | string | null | array $ value ): self
44
44
{
45
45
return new self ($ field , $ operator , $ value );
46
46
}
@@ -67,62 +67,122 @@ public static function fromArray(array $filter): self
67
67
);
68
68
}
69
69
70
- public static function equal (string $ field , mixed $ value ): self
70
+ /**
71
+ * @param string $field
72
+ * @param bool|float|int|string|null $value
73
+ * @return self
74
+ */
75
+ public static function equal (string $ field , bool |float |int |string |null $ value ): self
71
76
{
72
77
return self ::create ($ field , Operator::EQUAL , $ value );
73
78
}
74
79
75
- public static function notEqual (string $ field , mixed $ value ): self
80
+ /**
81
+ * @param string $field
82
+ * @param bool|float|int|string|null $value
83
+ * @return self
84
+ */
85
+ public static function notEqual (string $ field , bool |float |int |string |null $ value ): self
76
86
{
77
87
return self ::create ($ field , Operator::NOT_EQUAL , $ value );
78
88
}
79
89
80
- public static function greaterThan (string $ field , mixed $ value ): self
90
+ /**
91
+ * @param string $field
92
+ * @param bool|float|int|string|null $value
93
+ * @return self
94
+ */
95
+ public static function greaterThan (string $ field , bool |float |int |string |null $ value ): self
81
96
{
82
97
return self ::create ($ field , Operator::GT , $ value );
83
98
}
84
99
85
- public static function greaterOrEqualThan (string $ field , mixed $ value ): self
100
+ /**
101
+ * @param string $field
102
+ * @param bool|float|int|string|null $value
103
+ * @return self
104
+ */
105
+ public static function greaterOrEqualThan (string $ field , bool |float |int |string |null $ value ): self
86
106
{
87
107
return self ::create ($ field , Operator::GTE , $ value );
88
108
}
89
109
90
- public static function lessThan (string $ field , mixed $ value ): self
110
+ /**
111
+ * @param string $field
112
+ * @param bool|float|int|string|null $value
113
+ * @return self
114
+ */
115
+ public static function lessThan (string $ field , bool |float |int |string |null $ value ): self
91
116
{
92
117
return self ::create ($ field , Operator::LT , $ value );
93
118
}
94
119
95
- public static function lessOrEqualThan (string $ field , mixed $ value ): self
120
+ /**
121
+ * @param string $field
122
+ * @param bool|float|int|string|null $value
123
+ * @return self
124
+ */
125
+ public static function lessOrEqualThan (string $ field , bool |float |int |string |null $ value ): self
96
126
{
97
127
return self ::create ($ field , Operator::LTE , $ value );
98
128
}
99
129
100
- public static function in (string $ field , mixed $ value ): self
130
+ /**
131
+ * @param string $field
132
+ * @param array<scalar> $value
133
+ * @return self
134
+ */
135
+ public static function in (string $ field , array $ value ): self
101
136
{
102
137
return self ::create ($ field , Operator::IN , $ value );
103
138
}
104
139
105
- public static function notIn (string $ field , mixed $ value ): self
140
+ /**
141
+ * @param string $field
142
+ * @param array<scalar> $value
143
+ * @return self
144
+ */
145
+ public static function notIn (string $ field , array $ value ): self
106
146
{
107
147
return self ::create ($ field , Operator::NOT_IN , $ value );
108
148
}
109
149
110
- public static function like (string $ field , mixed $ value ): self
150
+ /**
151
+ * @param string $field
152
+ * @param bool|float|int|string|null $value
153
+ * @return self
154
+ */
155
+ public static function like (string $ field , bool |float |int |string |null $ value ): self
111
156
{
112
157
return self ::create ($ field , Operator::LIKE , $ value );
113
158
}
114
159
115
- public static function notLike (string $ field , mixed $ value ): self
160
+ /**
161
+ * @param string $field
162
+ * @param bool|float|int|string|null $value
163
+ * @return self
164
+ */
165
+ public static function notLike (string $ field , bool |float |int |string |null $ value ): self
116
166
{
117
167
return self ::create ($ field , Operator::NOT_LIKE , $ value );
118
168
}
119
169
120
- public static function contains (string $ field , mixed $ value ): self
170
+ /**
171
+ * @param string $field
172
+ * @param bool|float|int|string|null $value
173
+ * @return self
174
+ */
175
+ public static function contains (string $ field , bool |float |int |string |null $ value ): self
121
176
{
122
177
return self ::create ($ field , Operator::CONTAINS , $ value );
123
178
}
124
179
125
- public static function notContains (string $ field , mixed $ value ): self
180
+ /**
181
+ * @param string $field
182
+ * @param bool|float|int|string|null $value
183
+ * @return self
184
+ */
185
+ public static function notContains (string $ field , bool |float |int |string |null $ value ): self
126
186
{
127
187
return self ::create ($ field , Operator::NOT_CONTAINS , $ value );
128
188
}
@@ -150,9 +210,9 @@ public function operator(): Operator
150
210
/**
151
211
* Return the field value.
152
212
*
153
- * @return mixed
213
+ * @return scalar|null|array<scalar>
154
214
*/
155
- public function value (): mixed
215
+ public function value (): bool | float | int | string | null | array
156
216
{
157
217
return $ this ->value ;
158
218
}
0 commit comments