+ public static function email($value): bool {
+ if (function_exists('idn_to_ascii')) {
+ $parts = explode('@', $value);
+ foreach ($parts as &$part) {
+ // if the function returns FALSE then let filter_var have at it.
+ $part = self::idnToAsci($part) ?: $part;
+ if ($part === 'localhost') {
+ // if we are in a dev environment add .com to trick it into accepting localhost.
+ // this is a bit best-effort - ie we don't really care that it's in a bigger if.
+ $part .= '.com';
+ }
+ }
+ $value = implode('@', $parts);
+ }