Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Network.php
Original file line number Diff line number Diff line change
Expand Up @@ -352,11 +352,11 @@ public function valid()
}

/**
* @return int
* @return int|string
*/
public function count()
{
return (integer)$this->getBlockSize();
return $this->getBlockSize();
}

}
4 changes: 2 additions & 2 deletions src/Range.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}
4 changes: 3 additions & 1 deletion tests/NetworkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -290,6 +291,7 @@ public function getTestCountData()
return array(
array('127.0.0.0/31', 2),
array('2001:db8::/120', 256),
array('::/0', 340282366920938463463374607431768211456),
);
}
}
4 changes: 3 additions & 1 deletion tests/RangeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -140,6 +141,7 @@ public function getTestCountData()
return array(
array('127.0.0.0/31', 2),
array('2001:db8::/120', 256),
array('::/0', 340282366920938463463374607431768211456),
);
}

Expand Down