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