Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
samdark authored and StyleCIBot committed Dec 18, 2020
1 parent 15c425c commit 7a10f85
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/IpHelper.php
Expand Up @@ -99,8 +99,8 @@ public static function inRange(string $subnet, string $range): bool
assert(is_string($ip));
assert(is_string($net));

$ipVersion = static::getIpVersion($ip);
$netVersion = static::getIpVersion($net);
$ipVersion = self::getIpVersion($ip);
$netVersion = self::getIpVersion($net);
if ($ipVersion !== $netVersion) {
return false;
}
Expand All @@ -109,8 +109,8 @@ public static function inRange(string $subnet, string $range): bool
$mask ??= $maxMask;
$netMask ??= $maxMask;

$binIp = static::ip2bin($ip);
$binNet = static::ip2bin($net);
$binIp = self::ip2bin($ip);
$binNet = self::ip2bin($net);
$masked = substr($binNet, 0, (int)$netMask);

return ($masked === '' || strpos($binIp, $masked) === 0) && $mask >= $netMask;
Expand Down Expand Up @@ -147,7 +147,7 @@ public static function expandIPv6(string $ip): string
*/
public static function ip2bin(string $ip): string
{
if (static::getIpVersion($ip) === self::IPV4) {
if (self::getIpVersion($ip) === self::IPV4) {
$ipBinary = pack('N', ip2long($ip));
} elseif (@inet_pton('::1') === false) {
throw new \RuntimeException('IPv6 is not supported by inet_pton()!');
Expand Down Expand Up @@ -180,7 +180,7 @@ public static function getCidrBits(string $ip): int
if (preg_match('/^(?<ip>.{2,}?)(?:\/(?<bits>-?\d+))?$/', $ip, $matches) === 0) {
throw new \InvalidArgumentException("Unrecognized address $ip", 1);
}
$ipVersion = static::getIpVersion($matches['ip']);
$ipVersion = self::getIpVersion($matches['ip']);
$maxBits = $ipVersion === self::IPV6 ? self::IPV6_ADDRESS_LENGTH : self::IPV4_ADDRESS_LENGTH;
$bits = $matches['bits'] ?? null;
if ($bits === null) {
Expand Down

0 comments on commit 7a10f85

Please sign in to comment.