@@ -41,23 +41,23 @@ discard block |
||
| 41 | 41 | * @param int $count the number other bound |
| 42 | 42 | * @param bool $strict if true $network |
| 43 | 43 | */ |
| 44 | - public function __construct(Address $network, Address $netmask, bool $strict=true) |
|
| 44 | + public function __construct(Address $network, Address $netmask, bool $strict = true) |
|
| 45 | 45 | { |
| 46 | 46 | $finalNetmask = clone($netmask); |
| 47 | - if (!($netmask instanceof Netmask)) |
|
| 47 | + if(!($netmask instanceof Netmask)) |
|
| 48 | 48 | { |
| 49 | 49 | $finalNetmask = Netmask::fromAddress($netmask); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | // Verify parameters validity |
| 53 | - if( (($network->int() & $finalNetmask->int()) != $network->int()) && $strict) |
|
| 53 | + if((($network->int() & $finalNetmask->int())!=$network->int()) && $strict) |
|
| 54 | 54 | { |
| 55 | 55 | throw new RangeException(sprintf("Invalid network adress %s, this address is not usable with the netmask %s", (string)$network, (string)$finalNetmask)); |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | $finalNetwork = new Address($network->int() & $finalNetmask->int()); |
| 59 | 59 | |
| 60 | - parent::__construct($finalNetwork, $finalNetwork->shift(count($finalNetmask)-1)); |
|
| 60 | + parent::__construct($finalNetwork, $finalNetwork->shift(count($finalNetmask) - 1)); |
|
| 61 | 61 | $this->netmask = $finalNetmask; |
| 62 | 62 | } |
| 63 | 63 | |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | * @throws RangeException when network address and netmask does not form a valid subnet |
| 72 | 72 | * @return Subnet |
| 73 | 73 | */ |
| 74 | - public static function fromCidr(Address $network, int $cidr, bool $strict=true) |
|
| 74 | + public static function fromCidr(Address $network, int $cidr, bool $strict = true) |
|
| 75 | 75 | { |
| 76 | 76 | // Ensure CIDR is valid, use Address::fromCidr to have validation logic in only one place |
| 77 | 77 | $netmask = Netmask::fromCidr($cidr); |
@@ -105,10 +105,10 @@ discard block |
||
| 105 | 105 | * @throws InvaidArgumentException when provided sting cannot be converted to a valid subnet |
| 106 | 106 | * @return Subnet |
| 107 | 107 | */ |
| 108 | - public static function fromString(string $subnet, bool $strict=true) |
|
| 108 | + public static function fromString(string $subnet, bool $strict = true) |
|
| 109 | 109 | { |
| 110 | 110 | @list($address, $netmask, $trash) = explode('/', $subnet); |
| 111 | - if (!is_null($trash) || is_null($netmask)) |
|
| 111 | + if(!is_null($trash) || is_null($netmask)) |
|
| 112 | 112 | { |
| 113 | 113 | throw new InvalidArgumentException(sprintf("%s cannot be converted to subnet. Valid formats are : x.x.x.x/cidr or x.x.x.x/y.y.y.y", $subnet)); |
| 114 | 114 | } |
@@ -128,9 +128,9 @@ discard block |
||
| 128 | 128 | * @param string $separator The separator used between network an CIDR, defaults to / |
| 129 | 129 | * @return string |
| 130 | 130 | */ |
| 131 | - public function asDotQuadAndCidr(string $separator='/') |
|
| 131 | + public function asDotQuadAndCidr(string $separator = '/') |
|
| 132 | 132 | { |
| 133 | - return (string)$this->getNetworkAddress() . $separator . (string)$this->getNetmaskAddress()->asCidr(); |
|
| 133 | + return (string)$this->getNetworkAddress().$separator.(string)$this->getNetmaskAddress()->asCidr(); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | /** |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | public function shift(int $offset) |
| 177 | 177 | { |
| 178 | 178 | return static::fromCidr( |
| 179 | - $this->getNetworkAddress()->shift($offset*count($this)), |
|
| 179 | + $this->getNetworkAddress()->shift($offset * count($this)), |
|
| 180 | 180 | $this->getNetmaskAddress()->asCidr() |
| 181 | 181 | ); |
| 182 | 182 | } |