public static function email($value, $message = null, $propertyPath = null)
{
static::string($value, $message, $propertyPath);
if (!filter_var($value, FILTER_VALIDATE_EMAIL)) {
$message = sprintf($message ?: 'Value "%s" was expected to be a valid e-mail address.', static::stringify($value));
throw static::createException($value, $message, static::INVALID_EMAIL, $propertyPath);
} else {
$host = substr($value, strpos($value, '@') + 1);
// Likely not a FQDN, bug in PHP FILTER_VALIDATE_EMAIL prior to PHP 5.3.3
if (version_compare(PHP_VERSION, '5.3.3', '<') && strpos($host, '.') === false) {
$message = sprintf($message ?: 'Value "%s" was expected to be a valid e-mail address.', static::stringify($value));
throw static::createException($value, $message, static::INVALID_EMAIL, $propertyPath);
}
}
return true;
}