Skip to content

Commit

Permalink
add $forceIPv6
Browse files Browse the repository at this point in the history
  • Loading branch information
Babichev Maxim committed Sep 13, 2018
1 parent c52a459 commit f95b051
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Util.php
Expand Up @@ -41,14 +41,15 @@ public static function ip2long(string $ip): string

/**
* @param string $long
* @param bool $forceIPv6
* @return string
*/
public static function long2ip(string $long): string
public static function long2ip(string $long, bool $forceIPv6 = false): string
{
/**
* @var \GMP $long
*/
if (\gmp_cmp($long, static::IPv4_INT_MAX) > 0) {
if ($forceIPv6 || \gmp_cmp($long, static::IPv4_INT_MAX) > 0) {
return (string)\inet_ntop(
\str_pad(
\gmp_export($long),
Expand Down

0 comments on commit f95b051

Please sign in to comment.