Skip to content

Instantly share code, notes, and snippets.

@jayzeng
Created January 24, 2013 01:04
Show Gist options
  • Save jayzeng/4616545 to your computer and use it in GitHub Desktop.
Save jayzeng/4616545 to your computer and use it in GitHub Desktop.
<?php
class InvalidIpFormatException extends \InvalidArgumentException {}
class InvalidIpRangeException extends \InvalidArgumentException {}
class IpV4Validator
{
private $_ip;
public function __construct( $ipAddr ) {
$this->_ip = $ipAddr;
}
public function validate() {
if( false === $this->isIpv4() ) {
throw new InvalidIpFormatException( 'ip address must be ip v4' );
}
if( false === $this->isValidIpRange() {
throw new InvalidIpRangeException( 'ip address is invalid' );
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment