1 <?php namespace Modulework\Modules\Http\Utilities;
2 /*
3 * (c) Christian Gärtner <christiangaertner.film@googlemail.com>
4 * This file is part of the Modulework Framework
5 * License: View distributed LICENSE file
6 */
7
8
9 /**
10 * IP Validator
11 * Validates IPv4 and IPv6 address
12 */
13 interface IpValidatorInterface
14 {
15 /**
16 * Checks if it is a valid IPv4 or IPv6 address
17 * Private, reserved and broadcast addresses will return false.
18 * @param string $ip The IP to check
19 * @return boolean Whether it is a valid IP address
20 */
21 public static function all($ip);
22
23 /**
24 * Checks if the given string is valid IPv4 address
25 * @param string $ip The IP
26 * @return boolean Whether it is a valid IPv4 address
27 */
28 public static function ipv4($ip);
29
30 /**
31 * Checks if the given string is valid IPv6 address
32 * @param string $ip The IP
33 * @return boolean Whether it is a valid IPv6 address
34 */
35 public static function ipv6($ip);
36
37 /**
38 * Checks if the given string is a private IP address
39 * (in private range (RFC 1918))
40 * @param string $ip The IP
41 * @return boolean TRUE if the IP is a private address
42 */
43 public static function isPrivate($ip);
44
45 /**
46 * Checks if the given string is a reserved IP address
47 * (in reserved range)
48 * @param string $ip The IP
49 * @return boolean TRUE if the IP is a reserved IP address
50 */
51 public static function isReserved($ip);
52
53 /**
54 * Checks if the given string is a broadcast IP address
55 * e.g. 0.0.0.0
56 * @param string $ip The IP
57 * @return boolean TRUE if the IP is a broadcast address | FALSE if not a valid IP
58 */
59 public static function isBroadcast($ip);
60 }