Created
January 24, 2013 01:04
-
-
Save jayzeng/4616545 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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