function DomainLiteral::convertIPv4ToIPv6
1 call to DomainLiteral::convertIPv4ToIPv6()
- DomainLiteral::parse in vendor/
egulias/ email-validator/ src/ Parser/ DomainLiteral.php
File
-
vendor/
egulias/ email-validator/ src/ Parser/ DomainLiteral.php, line 148
Class
Namespace
Egulias\EmailValidator\ParserCode
public function convertIPv4ToIPv6(string $addressLiteralIPv4) : string {
$matchesIP = [];
$IPv4Match = preg_match(self::IPV4_REGEX, $addressLiteralIPv4, $matchesIP);
// Extract IPv4 part from the end of the address-literal (if there is one)
if ($IPv4Match > 0) {
$index = (int) strrpos($addressLiteralIPv4, $matchesIP[0]);
//There's a match but it is at the start
if ($index > 0) {
// Convert IPv4 part to IPv6 format for further testing
return substr($addressLiteralIPv4, 0, $index) . '0:0';
}
}
return $addressLiteralIPv4;
}