- var_dump: documentation ( source)
- preg_match: documentation ( source)
- sprintf: documentation ( source)
<?php
function assertValidLocale($locale)
{
if ($locale === null || 1 !== preg_match('/^[a-z0-9@_\\.\\-]*$/i', $locale)) {
throw new InvalidArgumentException(sprintf('Invalid "%s" locale.', $locale));
}
}
var_dump(assertValidLocale(null));