mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Apply fixes from StyleCI (#12117)
* Apply fixes from StyleCI * Disable style check
This commit is contained in:
@@ -37,9 +37,9 @@ class IPv4 extends IP
|
||||
public function __construct($ipv4)
|
||||
{
|
||||
$this->host_bits = 32;
|
||||
list($this->ip, $this->cidr) = $this->extractCidr($ipv4);
|
||||
[$this->ip, $this->cidr] = $this->extractCidr($ipv4);
|
||||
|
||||
if (!self::isValid($this->ip)) {
|
||||
if (! self::isValid($this->ip)) {
|
||||
throw new InvalidIpException("$ipv4 is not a valid ipv4 address");
|
||||
}
|
||||
}
|
||||
@@ -69,7 +69,8 @@ class IPv4 extends IP
|
||||
{
|
||||
$long = ip2long($netmask);
|
||||
$base = ip2long('255.255.255.255');
|
||||
return (int)(32 - log(($long ^ $base) + 1, 2));
|
||||
|
||||
return (int) (32 - log(($long ^ $base) + 1, 2));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,7 +88,7 @@ class IPv4 extends IP
|
||||
*/
|
||||
private function cidr2long($cidr)
|
||||
{
|
||||
return -1 << (32 - (int)$cidr);
|
||||
return -1 << (32 - (int) $cidr);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -97,13 +98,14 @@ class IPv4 extends IP
|
||||
*/
|
||||
public function inNetwork($network)
|
||||
{
|
||||
list($net, $cidr) = $this->extractCidr($network);
|
||||
if (!self::isValid($net)) {
|
||||
[$net, $cidr] = $this->extractCidr($network);
|
||||
if (! self::isValid($net)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$mask = $this->cidr2long($cidr);
|
||||
return ((ip2long($this->ip) & $mask) == (ip2long($net) & $mask));
|
||||
|
||||
return (ip2long($this->ip) & $mask) == (ip2long($net) & $mask);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,6 +129,6 @@ class IPv4 extends IP
|
||||
*/
|
||||
public function toSnmpIndex()
|
||||
{
|
||||
return (string)$this->ip;
|
||||
return (string) $this->ip;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user