diff --git a/src/Network.php b/src/Network.php index b68ce9e..f2ea07b 100644 --- a/src/Network.php +++ b/src/Network.php @@ -352,11 +352,11 @@ public function valid() } /** - * @return int + * @return int|string */ public function count() { - return (integer)$this->getBlockSize(); + return $this->getBlockSize(); } } diff --git a/src/Range.php b/src/Range.php index 7e045e6..b44a3ed 100644 --- a/src/Range.php +++ b/src/Range.php @@ -222,11 +222,11 @@ public function valid() } /** - * @return int + * @return string */ public function count() { - return (integer)bcadd(bcsub($this->lastIP->toLong(), $this->firstIP->toLong()), 1); + return (string)bcadd(bcsub($this->lastIP->toLong(), $this->firstIP->toLong()), 1); } } diff --git a/tests/NetworkTest.php b/tests/NetworkTest.php index 0ec3c1c..9572dc3 100644 --- a/tests/NetworkTest.php +++ b/tests/NetworkTest.php @@ -153,7 +153,8 @@ public function testNetworkIteration($data, $expected) */ public function testCount($data, $expected) { - $this->assertEquals($expected, count(Network::parse($data))); + $this->assertEquals($expected, Network::parse($data)->count()); + # $this->assertEquals($expected, count(Network::parse($data))); } public function getTestParseData() @@ -290,6 +291,7 @@ public function getTestCountData() return array( array('127.0.0.0/31', 2), array('2001:db8::/120', 256), + array('::/0', 340282366920938463463374607431768211456), ); } } diff --git a/tests/RangeTest.php b/tests/RangeTest.php index 4f81f8a..5c33120 100644 --- a/tests/RangeTest.php +++ b/tests/RangeTest.php @@ -56,7 +56,8 @@ public function testRangeIteration($data, $expected) */ public function testCount($data, $expected) { - $this->assertEquals($expected, count(Range::parse($data))); + $this->assertEquals($expected, Range::parse($data)->count()); + # $this->assertEquals($expected, count(Range::parse($data))); } public function getTestParseData() @@ -140,6 +141,7 @@ public function getTestCountData() return array( array('127.0.0.0/31', 2), array('2001:db8::/120', 256), + array('::/0', 340282366920938463463374607431768211456), ); }