Created
January 21, 2013 02:06
-
-
Save jayzeng/4583124 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 IpV4Validator | |
{ | |
private $_ip; | |
public function __construct( $ipAddr ) { | |
$this->_ip = $ipAddr; | |
} | |
public function validate() { | |
// let's assume we have isValid() | |
if( false === $this->isValid() ) { | |
throw new \InvalidArgumentException( $this->_ip . ' is not a valid IP v4 address' ); | |
} | |
} | |
public function isValid() { | |
// logic to validate ip v4 | |
return true; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment