@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | |
67 | 67 | } |
68 | 68 | |
69 | - $this->address = $address; |
|
69 | + $this->address = $address; |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -103,22 +103,22 @@ discard block |
||
103 | 103 | |
104 | 104 | public static function fromArray(Array $address) |
105 | 105 | { |
106 | - if( count($address) != 4) |
|
106 | + if (count($address)!=4) |
|
107 | 107 | { |
108 | 108 | throw new InvalidArgumentException(sprintf("Array must contain 4 digits, %d found", count($address))); |
109 | 109 | } |
110 | 110 | |
111 | 111 | $buffer = 0; |
112 | - foreach($address as $digit) |
|
112 | + foreach ($address as $digit) |
|
113 | 113 | { |
114 | - if (is_string($digit) ) |
|
114 | + if (is_string($digit)) |
|
115 | 115 | { |
116 | 116 | $digit = trim($digit); |
117 | 117 | if (strlen($digit)==0) |
118 | 118 | { |
119 | 119 | throw new InvalidArgumentException(sprintf("The array must contains only integers or strings with integer content , string found with empty value")); |
120 | 120 | } |
121 | - if ( $digit[0] == '-' && ctype_digit(ltrim($digit, '-')) ) |
|
121 | + if ($digit[0]=='-' && ctype_digit(ltrim($digit, '-'))) |
|
122 | 122 | { |
123 | 123 | // string type : "-123" |
124 | 124 | throw new OutOfBoundsException(sprintf("Cannot convert %d to Ipv4 addresss digit", $digit)); |
@@ -131,12 +131,12 @@ discard block |
||
131 | 131 | $digit = (int)$digit; |
132 | 132 | } |
133 | 133 | |
134 | - if (!is_integer($digit) ) |
|
134 | + if (!is_integer($digit)) |
|
135 | 135 | { |
136 | 136 | throw new InvalidArgumentException(sprintf("The array must contains only integers or strings with integer content , %s found", gettype($digit))); |
137 | 137 | } |
138 | 138 | |
139 | - if($digit<0 || $digit>0xff) |
|
139 | + if ($digit<0 || $digit>0xff) |
|
140 | 140 | { |
141 | 141 | throw new OutOfBoundsException(sprintf("Cannot convert %d to Ipv4 addresss digit", $digit)); |
142 | 142 | |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | */ |
175 | 175 | public static function fromCidr(int $cidr) |
176 | 176 | { |
177 | - if ($cidr<0 || $cidr>32 ) |
|
177 | + if ($cidr<0 || $cidr>32) |
|
178 | 178 | { |
179 | 179 | throw new OutOfBoundsException(sprintf("Invalid CIDR value %d", $cidr)); |
180 | 180 | } |
@@ -233,10 +233,10 @@ discard block |
||
233 | 233 | public function asCidr() |
234 | 234 | { |
235 | 235 | // Pas très élégant.... |
236 | - for ($cidr=32 ; $cidr>=0 ; $cidr--) |
|
236 | + for ($cidr = 32; $cidr>=0; $cidr--) |
|
237 | 237 | { |
238 | 238 | $n = (0xffffffff << (32 - $cidr)) & 0xffffffff; |
239 | - if( $n == $this->address ) |
|
239 | + if ($n==$this->address) |
|
240 | 240 | { |
241 | 241 | return $cidr; |
242 | 242 | } |
@@ -269,23 +269,23 @@ discard block |
||
269 | 269 | { |
270 | 270 | $higherOctet = $this->address >> 24; |
271 | 271 | |
272 | - if (($higherOctet & 0x80) == 0) { |
|
272 | + if (($higherOctet & 0x80)==0) { |
|
273 | 273 | return self::CLASS_A; |
274 | 274 | } |
275 | 275 | |
276 | - if (($higherOctet & 0xC0) == 0x80) { |
|
276 | + if (($higherOctet & 0xC0)==0x80) { |
|
277 | 277 | return self::CLASS_B; |
278 | 278 | } |
279 | 279 | |
280 | - if (($higherOctet & 0xE0) == 0xC0) { |
|
280 | + if (($higherOctet & 0xE0)==0xC0) { |
|
281 | 281 | return self::CLASS_C; |
282 | 282 | } |
283 | 283 | |
284 | - if (($higherOctet & 0xF0) == 0xE0) { |
|
284 | + if (($higherOctet & 0xF0)==0xE0) { |
|
285 | 285 | return self::CLASS_D; |
286 | 286 | } |
287 | 287 | |
288 | - if (($higherOctet & 0xF0) == 0xF0) { |
|
288 | + if (($higherOctet & 0xF0)==0xF0) { |
|
289 | 289 | return self::CLASS_E; |
290 | 290 | } |
291 | 291 | |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | { |
324 | 324 | $this->asCidr(); |
325 | 325 | } |
326 | - catch(DomainException $e) |
|
326 | + catch (DomainException $e) |
|
327 | 327 | { |
328 | 328 | return false; |
329 | 329 | } |
@@ -351,8 +351,8 @@ discard block |
||
351 | 351 | Subnet::fromCidr(Address::fromString("172.16.0.0"), 12), |
352 | 352 | Subnet::fromCidr(Address::fromString("192.168.0.0"), 16), |
353 | 353 | ); |
354 | - foreach($subnets as $subnet) { |
|
355 | - if($subnet->contains($this)) { |
|
354 | + foreach ($subnets as $subnet) { |
|
355 | + if ($subnet->contains($this)) { |
|
356 | 356 | return true; |
357 | 357 | } |
358 | 358 | } |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | */ |
384 | 384 | public function isPrivate() |
385 | 385 | { |
386 | - return ($this->isRFC1918() || $this->isRFC6598()); |
|
386 | + return ($this->isRFC1918() || $this->isRFC6598()); |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | /** |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | */ |
394 | 394 | public function isMulticast() |
395 | 395 | { |
396 | - return $this->getClass() === self::CLASS_D; |
|
396 | + return $this->getClass()===self::CLASS_D; |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | /** |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | */ |
405 | 405 | public function match(Address $address) |
406 | 406 | { |
407 | - return $this->int() == $address->int(); |
|
407 | + return $this->int()==$address->int(); |
|
408 | 408 | } |
409 | 409 | |
410 | 410 | /** |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | */ |
419 | 419 | public function shift(int $offset) |
420 | 420 | { |
421 | - return self::fromInteger($this->address+$offset); |
|
421 | + return self::fromInteger($this->address + $offset); |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | /** |