@@ 183-191 (lines=9) @@ | ||
180 | static::notEq($value, '', $message); |
|
181 | } |
|
182 | ||
183 | public static function integer($value, $message = '') |
|
184 | { |
|
185 | if (!is_int($value)) { |
|
186 | static::reportInvalidArgument(sprintf( |
|
187 | $message ?: 'Expected an integer. Got: %s', |
|
188 | static::typeToString($value) |
|
189 | )); |
|
190 | } |
|
191 | } |
|
192 | ||
193 | public static function integerish($value, $message = '') |
|
194 | { |
|
@@ 193-201 (lines=9) @@ | ||
190 | } |
|
191 | } |
|
192 | ||
193 | public static function integerish($value, $message = '') |
|
194 | { |
|
195 | if (!is_numeric($value) || $value != (int) $value) { |
|
196 | static::reportInvalidArgument(sprintf( |
|
197 | $message ?: 'Expected an integerish value. Got: %s', |
|
198 | static::typeToString($value) |
|
199 | )); |
|
200 | } |
|
201 | } |
|
202 | ||
203 | public static function float($value, $message = '') |
|
204 | { |
|
@@ 203-211 (lines=9) @@ | ||
200 | } |
|
201 | } |
|
202 | ||
203 | public static function float($value, $message = '') |
|
204 | { |
|
205 | if (!is_float($value)) { |
|
206 | static::reportInvalidArgument(sprintf( |
|
207 | $message ?: 'Expected a float. Got: %s', |
|
208 | static::typeToString($value) |
|
209 | )); |
|
210 | } |
|
211 | } |
|
212 | ||
213 | public static function numeric($value, $message = '') |
|
214 | { |
|
@@ 213-221 (lines=9) @@ | ||
210 | } |
|
211 | } |
|
212 | ||
213 | public static function numeric($value, $message = '') |
|
214 | { |
|
215 | if (!is_numeric($value)) { |
|
216 | static::reportInvalidArgument(sprintf( |
|
217 | $message ?: 'Expected a numeric. Got: %s', |
|
218 | static::typeToString($value) |
|
219 | )); |
|
220 | } |
|
221 | } |
|
222 | ||
223 | public static function natural($value, $message = '') |
|
224 | { |
|
@@ 233-241 (lines=9) @@ | ||
230 | } |
|
231 | } |
|
232 | ||
233 | public static function boolean($value, $message = '') |
|
234 | { |
|
235 | if (!is_bool($value)) { |
|
236 | static::reportInvalidArgument(sprintf( |
|
237 | $message ?: 'Expected a boolean. Got: %s', |
|
238 | static::typeToString($value) |
|
239 | )); |
|
240 | } |
|
241 | } |
|
242 | ||
243 | public static function scalar($value, $message = '') |
|
244 | { |
|
@@ 243-251 (lines=9) @@ | ||
240 | } |
|
241 | } |
|
242 | ||
243 | public static function scalar($value, $message = '') |
|
244 | { |
|
245 | if (!is_scalar($value)) { |
|
246 | static::reportInvalidArgument(sprintf( |
|
247 | $message ?: 'Expected a scalar. Got: %s', |
|
248 | static::typeToString($value) |
|
249 | )); |
|
250 | } |
|
251 | } |
|
252 | ||
253 | public static function object($value, $message = '') |
|
254 | { |
|
@@ 253-261 (lines=9) @@ | ||
250 | } |
|
251 | } |
|
252 | ||
253 | public static function object($value, $message = '') |
|
254 | { |
|
255 | if (!is_object($value)) { |
|
256 | static::reportInvalidArgument(sprintf( |
|
257 | $message ?: 'Expected an object. Got: %s', |
|
258 | static::typeToString($value) |
|
259 | )); |
|
260 | } |
|
261 | } |
|
262 | ||
263 | public static function resource($value, $type = null, $message = '') |
|
264 | { |
|
@@ 281-289 (lines=9) @@ | ||
278 | } |
|
279 | } |
|
280 | ||
281 | public static function isCallable($value, $message = '') |
|
282 | { |
|
283 | if (!is_callable($value)) { |
|
284 | static::reportInvalidArgument(sprintf( |
|
285 | $message ?: 'Expected a callable. Got: %s', |
|
286 | static::typeToString($value) |
|
287 | )); |
|
288 | } |
|
289 | } |
|
290 | ||
291 | public static function isArray($value, $message = '') |
|
292 | { |
|
@@ 291-299 (lines=9) @@ | ||
288 | } |
|
289 | } |
|
290 | ||
291 | public static function isArray($value, $message = '') |
|
292 | { |
|
293 | if (!is_array($value)) { |
|
294 | static::reportInvalidArgument(sprintf( |
|
295 | $message ?: 'Expected an array. Got: %s', |
|
296 | static::typeToString($value) |
|
297 | )); |
|
298 | } |
|
299 | } |
|
300 | ||
301 | public static function isTraversable($value, $message = '') |
|
302 | { |
|
@@ 349-358 (lines=10) @@ | ||
346 | } |
|
347 | } |
|
348 | ||
349 | public static function isInstanceOf($value, $class, $message = '') |
|
350 | { |
|
351 | if (!($value instanceof $class)) { |
|
352 | static::reportInvalidArgument(sprintf( |
|
353 | $message ?: 'Expected an instance of %2$s. Got: %s', |
|
354 | static::typeToString($value), |
|
355 | $class |
|
356 | )); |
|
357 | } |
|
358 | } |
|
359 | ||
360 | public static function notInstanceOf($value, $class, $message = '') |
|
361 | { |
|
@@ 360-369 (lines=10) @@ | ||
357 | } |
|
358 | } |
|
359 | ||
360 | public static function notInstanceOf($value, $class, $message = '') |
|
361 | { |
|
362 | if ($value instanceof $class) { |
|
363 | static::reportInvalidArgument(sprintf( |
|
364 | $message ?: 'Expected an instance other than %2$s. Got: %s', |
|
365 | static::typeToString($value), |
|
366 | $class |
|
367 | )); |
|
368 | } |
|
369 | } |
|
370 | ||
371 | public static function isEmpty($value, $message = '') |
|
372 | { |