Skip to content

Instantly share code, notes, and snippets.

@jayzeng
Created January 21, 2013 02:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jayzeng/4583124 to your computer and use it in GitHub Desktop.
Save jayzeng/4583124 to your computer and use it in GitHub Desktop.
<?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