public static function contractIpv6(string $ip): string
    {
        if (!Validator::ipv6($ip)) {
            throw new \InvalidArgumentException(sprintf('"%s" is not a valid IPv6 address.', $ip));
        }

        return inet_ntop(inet_pton($ip));
    }
public static function contractIpv6(string $ip): string
    {
        if (!Validator::ipv6($ip)) {
            throw new \InvalidArgumentException(sprintf('"%s" is not a valid IPv6 address.', $ip));
        }

        return inet_ntop(inet_pton($ip));
    }
public static function contractIpv6 ( string $ ip ) : string { if ( ! Validator :: ipv6 ( $ ip ) ) { throw new \ InvalidArgumentException ( sprintf ( '"%s" is not a valid IPv6 address.' , $ ip ) ) ; } return inet_ntop ( inet_pton ( $ ip ) ) ; }
Takes a valid IPv6 address and contracts it
to its shorter version.

E.g.: 2001:0000:0000:acad:0000:0000:0000:0001 -> 2001:0:0:acad::1

Note: If there is more than one set of consecutive hextets, the function
will favour the larger of the sets. If both sets of zeroes are the same
the first will be favoured in the omission of zeroes.

E.g.: 2001:0000:0000:ab80:2390:0000:0000:000a -> 2001:0:0:ab80:2390::a

@param string $ip IPv6 address

@throws \InvalidArgumentException

@return string Contracted IPv6 address
Takes a valid IPv6 address and contracts it to its shorter version .