1 | <?php |
||
21 | trait HostIpTrait |
||
22 | { |
||
23 | /** |
||
24 | * Is the Host an IPv4 |
||
25 | * |
||
26 | * @var bool |
||
27 | */ |
||
28 | protected $hostAsIpv4 = false; |
||
29 | |||
30 | /** |
||
31 | * Is the Host an IPv6 |
||
32 | * |
||
33 | * @var bool |
||
34 | */ |
||
35 | protected $hostAsIpv6 = false; |
||
36 | |||
37 | /** |
||
38 | * Tell whether the IP has a zone Identifier |
||
39 | * |
||
40 | * @var bool |
||
41 | */ |
||
42 | protected $hasZoneIdentifier = false; |
||
43 | |||
44 | /** |
||
45 | * IPv6 Local Link binary-like prefix |
||
46 | * |
||
47 | * @var string |
||
48 | */ |
||
49 | protected static $local_link_prefix = '1111111010'; |
||
50 | |||
51 | /** |
||
52 | * Validate a Host as an IP |
||
53 | * |
||
54 | 538 | * @param string $str |
|
55 | * |
||
56 | 538 | * @return array |
|
57 | */ |
||
58 | protected function validateIpHost($str) |
||
77 | |||
78 | 8 | /** |
|
79 | * validate and filter a Ipv6 Hostname |
||
80 | 8 | * |
|
81 | * @param string $str |
||
82 | * |
||
83 | * @return string|false |
||
84 | */ |
||
85 | protected function filterIpv6Host($str) |
||
98 | |||
99 | /** |
||
100 | 574 | * Scope Ip validation according to RFC6874 rules |
|
101 | 40 | * |
|
102 | 40 | * @see http://tools.ietf.org/html/rfc6874#section-2 |
|
103 | * @see http://tools.ietf.org/html/rfc6874#section-4 |
||
104 | 40 | * |
|
105 | * @param string $ip The ip to validate |
||
106 | * |
||
107 | 544 | * @return string |
|
108 | */ |
||
109 | protected function validateScopedIpv6($ip) |
||
125 | 586 | ||
126 | /** |
||
127 | * Tell whether the submitted string is a local link IPv6 |
||
128 | 20 | * |
|
129 | * @param string $ipv6 |
||
130 | * |
||
131 | * @return bool |
||
132 | */ |
||
133 | protected function isLocalLink($ipv6) |
||
146 | |||
147 | /** |
||
148 | 16 | * Format an IP for string representation of the Host |
|
149 | 16 | * |
|
150 | 4 | * @param string $ip_address IP address |
|
151 | * |
||
152 | * @return string |
||
153 | 12 | */ |
|
154 | protected function formatIp($ip_address) |
||
167 | } |
||
168 |