Repository: mlocati/ip-lib (php)

Issue:
containsRange checks are not symmetric with explicit subnet masks involved
An edge case for `containsRange` I ran into; I was expecting both these checks to return true:

```
use IPLib\Factory;

$a = Factory::rangeFromString("1.2.3.4");
$b = Factory::rangeFromString("1.2.3.4/32");

$a->containsRange($b); // false
$b->containsRange($a); // true
```

For context, this came up during some blacklisting logic, where I want to check a user-provided input address or range against a predefined list of excluded IPs or ranges. Both sides are 'input' in the sense that they could come from configuration or from users, so either side could conceivably contain an explicit /32 suffix.

Pull request description:
Fix Range\Single::containsRange() method
Fix #75

Patch:
diff --git a/src/Range/Single.php b/src/Range/Single.php
index c3941a7..ec3531f 100644
--- a/src/Range/Single.php
+++ b/src/Range/Single.php
@@ -143,23 +143,6 @@ class Single extends AbstractRange
         return $result;
     }
 
-    /**
-     * {@inheritdoc}
-     *
-     * @see \IPLib\Range\RangeInterface::containsRange()
-     */
-    public function containsRange(RangeInterface $range)
-    {
-        $result = false;
-        if ($range->getAddressType() === $this->getAddressType()) {
-            if ($range->toString(false) === $this->toString(false)) {
-                $result = true;
-            }
-        }
-
-        return $result;
-    }
-
     /**
      * {@inheritdoc}
      *


Test patch:
diff --git a/test/tests/Membership/MembershipTest.php b/test/tests/Membership/MembershipTest.php
index 581548e..f23908f 100644
--- a/test/tests/Membership/MembershipTest.php
+++ b/test/tests/Membership/MembershipTest.php
@@ -124,4 +124,27 @@ class MembershipTest extends DBTestCase
             )
         );
     }
+
+    public function sameRangeProvider()
+    {
+        return array(
+            array('1.2.3.4', '1.2.3.4/32'),
+        );
+    }
+
+    /**
+     * @dataProvider sameRangeProvider
+     *
+     * @param string $range1
+     * @param string $range2
+     */
+    public function testSameRange($range1, $range2)
+    {
+        $rangeObject1 = Factory::rangeFromString($range1);
+        $rangeObject2 = Factory::rangeFromString($range2);
+        $this->assertTrue($rangeObject1->containsRange($rangeObject1), "{$range1} should contain {$range1}");
+        $this->assertTrue($rangeObject2->containsRange($rangeObject2), "{$range2} should contain {$range2}");
+        $this->assertTrue($rangeObject1->containsRange($rangeObject2), "{$range1} should contain {$range2}");
+        $this->assertTrue($rangeObject2->containsRange($rangeObject1), "{$range2} should contain {$range1}");
+    }
 }