1 | <?php |
||
12 | class Address |
||
13 | { |
||
14 | /** |
||
15 | * Used to request dot-notated string representation of IP from \JAAulde\IP\V4\Address::get. |
||
16 | * |
||
17 | * @const |
||
18 | * |
||
19 | * @see \JAAulde\IP\V4\Address::get |
||
20 | */ |
||
21 | const FORMAT_DOTTED_NOTATION = 0; |
||
22 | /** |
||
23 | * Used to request integer representation of IP from \JAAulde\IP\V4\Address::get. |
||
24 | * |
||
25 | * @const |
||
26 | * |
||
27 | * @see \JAAulde\IP\V4\Address::get |
||
28 | */ |
||
29 | const FORMAT_LONG_NOTATION = 1; |
||
30 | |||
31 | /** |
||
32 | * @var int The integer value of the address (generally produced by ip2long()) |
||
33 | */ |
||
34 | protected $address; |
||
35 | |||
36 | /** |
||
37 | * Constructor |
||
38 | * |
||
39 | * @param string|int $ip The IP address (in dot-notation-string format or integer) to be represented by the instance |
||
40 | */ |
||
41 | public function __construct($ip) |
||
45 | |||
46 | /** |
||
47 | * Format and validate for given string or integer formatted IPV4 network address. |
||
48 | * |
||
49 | * @param string|int $ip The IP address (in dot-notation-string format or integer) to be represented by the instance |
||
50 | * |
||
51 | * @throws Exception |
||
52 | */ |
||
53 | protected function setFromMixedSource($ip) |
||
84 | |||
85 | /** |
||
86 | * Set the value of the address to the integer representation (compensating for addresses which converted to negative on 32bit systems). |
||
87 | * |
||
88 | * @param integer $address |
||
89 | */ |
||
90 | protected function set($address) |
||
98 | |||
99 | /** |
||
100 | * Get the integer or dot-notated-string representation of the address. |
||
101 | * |
||
102 | * @param int $format Whether to return as integer (\JAAulde\IP\V4\Address::FORMAT_LONG_NOTATION) or dot-notation-string (\JAAulde\IP\V4\Address::FORMAT_DOTTED_NOTATION) |
||
103 | * |
||
104 | * @return string|int |
||
105 | */ |
||
106 | public function get($format = self::FORMAT_LONG_NOTATION) |
||
110 | |||
111 | /** |
||
112 | * Output dotted notation on conversion to string. |
||
113 | * |
||
114 | * @uses \JAAulde\IP\V4\Address::get |
||
115 | * |
||
116 | * @return string |
||
117 | */ |
||
118 | public function __toString() |
||
122 | } |
||
123 |