Completed
Branch master (dbb22f)
by Matthieu
01:51
created
src/IPv4/Subnet.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
         // Ensure CIDR is valid, use Address::fromCidr to have validation logic in only one place 
58 58
         $netmask = Address::fromCidr($cidr)->int();
59 59
         $address = $network->int();
60
-        if( ($address & $netmask) != $address)
60
+        if(($address & $netmask)!=$address)
61 61
         {
62 62
             throw new RangeException(sprintf("Invalid network adress %s, this address is not usable with the CIDR %d", (string)$network, $cidr));
63 63
         }
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
     public function getBroadcastAddress()
153 153
     {
154 154
         $netmask_inverted = (0xffffffff & ~$this->netmask);
155
-        $intBroadcast =  ($this->network->int() | $netmask_inverted);
155
+        $intBroadcast = ($this->network->int() | $netmask_inverted);
156 156
         return Address::fromInteger($intBroadcast);
157 157
     }
158 158
 
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
      */
165 165
     public function contains(Address $ip)
166 166
     {
167
-        return (($this->network->int() & $this->netmask) == ($ip->int() & $this->netmask));
167
+        return (($this->network->int() & $this->netmask)==($ip->int() & $this->netmask));
168 168
     }
169 169
 
170 170
     /**
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
      */
188 188
     public function count()
189 189
     {
190
-        return (~$this->netmask & 0xffffffff)+1; 
190
+        return (~$this->netmask & 0xffffffff) + 1; 
191 191
     }
192 192
 
193 193
     /**
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
     public function shift(int $offset)
214 214
     {
215 215
         // On décale l'adresse de réseau en fonction de la taille du subnet
216
-        $newNetwork = Address::fromInteger($this->getNetworkAddress()->int() + ($offset*count($this)));
216
+        $newNetwork = Address::fromInteger($this->getNetworkAddress()->int() + ($offset * count($this)));
217 217
 
218 218
         // On évite de manipuler directement les propriétés network d'un nouvek objet 
219 219
         // pour profiter de la validation en cas de dépassement des bornes.
@@ -273,19 +273,19 @@  discard block
 block discarded – undo
273 273
      */
274 274
     public function offsetExists($offset)
275 275
     {
276
-        if (is_string($offset))
276
+        if(is_string($offset))
277 277
         {
278
-            if (!preg_match('/^-?[0-9]+$/', $offset))
278
+            if(!preg_match('/^-?[0-9]+$/', $offset))
279 279
             {
280 280
                 throw new InvalidArgumentException(sprintf('Invalid key type (%s), only integers or strings representing integers can be used to acces address in a Subnet', gettype($offset)));
281 281
             }
282 282
             $offset = (int)$offset;
283 283
         }
284
-        if (!is_int($offset))
284
+        if(!is_int($offset))
285 285
         {
286 286
             throw new InvalidArgumentException(sprintf('Invalid key type (%s), only integers or strings representing integers can be used to acces address in a Subnet', gettype($offset)));
287 287
         }
288
-        if ($offset<0 || $offset>=count($this))
288
+        if($offset<0 || $offset>=count($this))
289 289
         {
290 290
             return false;
291 291
         }
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 
306 306
     public function  offsetGet($offset)
307 307
     {
308
-        if (!$this->offsetExists($offset))
308
+        if(!$this->offsetExists($offset))
309 309
         {
310 310
             throw new OutOfBoundsException();
311 311
         }
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
      * @throws BadMethodCallException always
323 323
      */ 
324 324
 
325
-    public function offsetSet($offset,  $value)
325
+    public function offsetSet($offset, $value)
326 326
     {
327 327
         throw new BadMethodCallException(sprintf("class %s is immutable, cannot modify an address value in a Subnet", self::class));
328 328
     }
Please login to merge, or discard this patch.