@@ 467-475 (lines=9) @@ | ||
464 | * @param null $exception |
|
465 | * @throws Exception |
|
466 | */ |
|
467 | public static function isArrayAccessible($value, $message = '', $exception = null) |
|
468 | { |
|
469 | if (!\is_array($value) && !($value instanceof ArrayAccess)) { |
|
470 | static::throwException(\sprintf( |
|
471 | $message ?: 'Expected an array accessible. Got: %s', |
|
472 | static::typeToString($value) |
|
473 | ), $exception); |
|
474 | } |
|
475 | } |
|
476 | ||
477 | /** |
|
478 | * @psalm-assert countable $value |
|
@@ 485-493 (lines=9) @@ | ||
482 | * @param null $exception |
|
483 | * @throws Exception |
|
484 | */ |
|
485 | public static function isCountable($value, $message = '', $exception = null) |
|
486 | { |
|
487 | if (!\is_array($value) && !($value instanceof Countable)) { |
|
488 | static::throwException(\sprintf( |
|
489 | $message ?: 'Expected a countable. Got: %s', |
|
490 | static::typeToString($value) |
|
491 | ), $exception); |
|
492 | } |
|
493 | } |
|
494 | ||
495 | /** |
|
496 | * @psalm-assert iterable $value |
|
@@ 503-511 (lines=9) @@ | ||
500 | * @param null $exception |
|
501 | * @throws Exception |
|
502 | */ |
|
503 | public static function isIterable($value, $message = '', $exception = null) |
|
504 | { |
|
505 | if (!\is_array($value) && !($value instanceof Traversable)) { |
|
506 | static::throwException(\sprintf( |
|
507 | $message ?: 'Expected an iterable. Got: %s', |
|
508 | static::typeToString($value) |
|
509 | ), $exception); |
|
510 | } |
|
511 | } |
|
512 | ||
513 | /** |
|
514 | * @psalm-template ExpectedType of object |