/** * Parse a string for via. * * @api BLW * @since 1.0.0 * @uses \BLW\Type\AEmailAddress::getRegex() AEmailAdress::getRegex() * * @param string $Test * String to search. * @return string Returns empty string in case of error. */ public static function parseVia($Test) { // Via Regex $Via = sprintf('(?:%s\\s*\\x2f\\s*)?%s(?:%s|%s)%s?', self::TOKEN, self::TOKEN, AEmailAddress::getRegex('domain'), self::TOKEN, AEmailAddress::getRegex('comment')); // Match Regex `via` if (preg_match("!{$Via}!", @substr($Test, 0, 1024), $m)) { return $m[0]; } // Default return ''; }
/** * Parse a string for cache-directive. * * @api BLW * @since 1.0.0 * @uses \BLW\Type\AEmailAddress::getRegex() AEmailAddress::getRegex() * * @param string $Test * String to search. * @return string Returns `no-cache` in case of error. */ public static function parseDirective($Test) { $Directive = sprintf('%s(?:\\s*\\x3d%s)?', self::TOKEN, AEmailAddress::getRegex('word')); // Match Regex `cache-directive` if (preg_match("!{$Directive}!", @substr($Test, 0, 1024), $m)) { return $m[0]; } // Default return 'no-cache'; }
/** * Parse a string for unique id. * * @api BLW * @since 1.0.0 * @uses \BLW\Type\AEmailAddress::getRegex() * * @param string $Test * String to search. * @return string Returns <code>uniqid(id, true)</code> in case of error. */ public static function parseID($Test) { // addr-spec Regex $AddrSpec = AEmailAddress::getRegex('addr-spec'); // Match Regex `addr-spec` if (preg_match("!{$AddrSpec}!", @strval($Test), $m)) { return $m[0]; } // Default return uniqid('id', true) . '@' . (@$_SERVER['HTTP_HOST'] ?: @$_SERVER['SERVER_NAME'] ?: @$_SERVER['SERVER_ADDR'] ?: '0.0.0.0'); }