public static function validIp($value)
    {
        if (empty($value)) {
            throw new \InvalidArgumentException("Empty IP address given.");
        }

        if (!filter_var($value, FILTER_VALIDATE_IP)) {
            throw new \InvalidArgumentException("Invalid IP address given.");
        }

        return $value;
    }
public static function validIp($value)
    {
        if (empty($value)) {
            throw new \InvalidArgumentException("Empty IP address given.");
        }

        if (!filter_var($value, FILTER_VALIDATE_IP)) {
            throw new \InvalidArgumentException("Invalid IP address given.");
        }

        return $value;
    }
public static function validIp ( $ value ) { if ( empty ( $ value ) ) { throw new \ InvalidArgumentException ( "Empty IP address given." ) ; } if ( ! filter_var ( $ value , FILTER_VALIDATE_IP ) ) { throw new \ InvalidArgumentException ( "Invalid IP address given." ) ; } return $ value ; }
Validates the given value using the PHP filter_var with
FILTER_VALIDATE_IP.

@param string $value IP to validate

@return string ipv4 or ipv6 (may still be in private or reserved range)

@throws \InvalidArgumentException in case of validation errors (invalid or empty ip)
Validates the given value using the PHP filter_var with FILTER_VALIDATE_IP .