Skip to content

Commit

Permalink
Added getTrueCidr() method
Browse files Browse the repository at this point in the history
  • Loading branch information
lifo101 committed May 5, 2014
1 parent d58c04d commit 3597b6f
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/Lifo/IP/CIDR.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,31 @@ public function isIPv6()
* and the starting IP is not on a valid network boundrary (eg: Displaying
* an IP from an interface).
*
* @return string IP in CIDR notation "ipaddr/prefix"
* <b>Note: The CIDR block returned is NOT always bit aligned.</b>
*
* @return string IP in CIDR notation "start_ip/prefix"
*/
public function getCidr()
{
return $this->start . '/' . $this->prefix;
}

/**
* Get the TRUE cidr notation for the subnet block.
*
* This is useful for when you want a string representation of the IP/prefix
* and the starting IP is not on a valid network boundrary (eg: Displaying
* an IP from an interface).
*
* <b>Note: The CIDR block returned is ALWAYS bit aligned.</b>
*
* @return string IP in CIDR notation "network/prefix"
*/
public function getTrueCidr()
{
return $this->getNetwork() . '/' . $this->prefix;
}

/**
* Get the [low,high] range of the CIDR block
*
Expand Down

0 comments on commit 3597b6f

Please sign in to comment.