public static function GuardUtils::guardForArrayOrTraversable in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/zendframework/zend-stdlib/src/Guard/GuardUtils.php \Zend\Stdlib\Guard\GuardUtils::guardForArrayOrTraversable()
Verifies that the data is an array or Traversable
Parameters
mixed $data the data to verify:
string $dataName the data name:
string $exceptionClass FQCN for the exception:
Throws
\Exception
File
- vendor/
zendframework/ zend-stdlib/ src/ Guard/ GuardUtils.php, line 33
Class
- GuardUtils
- Static guard helper class
Namespace
Zend\Stdlib\GuardCode
public static function guardForArrayOrTraversable($data, $dataName = 'Argument', $exceptionClass = self::DEFAULT_EXCEPTION_CLASS) {
if (!is_array($data) && !$data instanceof Traversable) {
$message = sprintf('%s must be an array or Traversable, [%s] given', $dataName, is_object($data) ? get_class($data) : gettype($data));
throw new $exceptionClass($message);
}
}