added ip(v4+v6) validation methods.

This commit is contained in:
Marcel Naeve 2016-05-12 17:04:31 +02:00
parent 9a685c1f8d
commit d81e185041
1 changed files with 30 additions and 0 deletions

View File

@ -58,4 +58,34 @@ class Validate
return $results;
}
/**
* Static function for validating a IP Address.
* @param string $address IP address
* @return bool is the IP Address valid?
*/
static function ip(string $address) : bool
{
return false !== filter_var($address, FILTER_VALIDATE_IP);
}
/**
* Static function for validating a IPv4 Address.
* @param string $address IPv4 address
* @return bool is the IPv4 Address valid?
*/
static function ipv4 (string $address) : bool
{
return false !== filter_var($address, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4);
}
/**
* Static function for validating a IPv6 Address.
* @param string $address IPv6 address
* @return bool is the IPv6 Address valid?
*/
static function ipv6 (string $address) : bool
{
return false !== filter_var($address, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6);
}
}