|
1
|
|
|
<?php |
|
2
|
|
|
namespace Subreality\Dilmun\Anshar\Http\UriParts; |
|
3
|
|
|
|
|
4
|
|
|
/** |
|
5
|
|
|
* Class Host |
|
6
|
|
|
* @package Subreality\Dilmun\Anshar\Http\UriParts |
|
7
|
|
|
*/ |
|
8
|
|
|
class Host extends AbstractUriPart |
|
9
|
|
|
{ |
|
10
|
|
|
protected $unencoded_characters = array( |
|
11
|
|
|
"[", |
|
12
|
|
|
"]", |
|
13
|
|
|
":", |
|
14
|
|
|
); |
|
15
|
|
|
|
|
16
|
|
|
protected $compositions = array( |
|
17
|
|
|
"unreserved_characters", |
|
18
|
|
|
"sub_delims_characters", |
|
19
|
|
|
); |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Host constructor. Accepts a string representing a URI host component. Construction will throw an exception if |
|
23
|
|
|
* the host is not a string. |
|
24
|
|
|
* |
|
25
|
|
|
* Construction accepts strings that have been percent-encoded as well as strings that have not been percent-encoded |
|
26
|
|
|
* and will encode invalid characters. |
|
27
|
|
|
* |
|
28
|
|
|
* Construction with a string that includes both encoded and decoded characters will be assumed to be an encoded |
|
29
|
|
|
* string, resulting in double-encoding. |
|
30
|
|
|
* |
|
31
|
|
|
* host = IP-literal / IPv4address / reg-name |
|
32
|
|
|
* |
|
33
|
|
|
* IP-literal = "[" ( IPv6address / IPvFuture ) "]" |
|
34
|
|
|
* |
|
35
|
|
|
* IPvFuture = "v" 1*HEXDIG "." 1*( unreserved / sub-delims / ":" ) |
|
36
|
|
|
* |
|
37
|
|
|
* IPv6address = 6( h16 ":" ) ls32 |
|
38
|
|
|
* / "::" 5( h16 ":" ) ls32 |
|
39
|
|
|
* / [ h16 ] "::" 4( h16 ":" ) ls32 |
|
40
|
|
|
* / [ *1( h16 ":" ) h16 ] "::" 3( h16 ":" ) ls32 |
|
41
|
|
|
* / [ *2( h16 ":" ) h16 ] "::" 2( h16 ":" ) ls32 |
|
42
|
|
|
* / [ *3( h16 ":" ) h16 ] "::" h16 ":" ls32 |
|
43
|
|
|
* / [ *4( h16 ":" ) h16 ] "::" ls32 |
|
44
|
|
|
* / [ *5( h16 ":" ) h16 ] "::" h16 |
|
45
|
|
|
* / [ *6( h16 ":" ) h16 ] "::" |
|
46
|
|
|
* |
|
47
|
|
|
* h16 = 1*4HEXDIG |
|
48
|
|
|
* ls32 = ( h16 ":" h16 ) / IPv4address |
|
49
|
|
|
* IPv4address = dec-octet "." dec-octet "." dec-octet "." dec-octet |
|
50
|
|
|
* |
|
51
|
|
|
* dec-octet = DIGIT ; 0-9 |
|
52
|
|
|
* / %x31-39 DIGIT ; 10-99 |
|
53
|
|
|
* / "1" 2DIGIT ; 100-199 |
|
54
|
|
|
* / "2" %x30-34 DIGIT ; 200-249 |
|
55
|
|
|
* / "25" %x30-35 ; 250-255 |
|
56
|
|
|
* |
|
57
|
|
|
* reg-name = *( unreserved / pct-encoded / sub-delims ) |
|
58
|
|
|
* |
|
59
|
|
|
* @see https://tools.ietf.org/html/rfc3986#appendix-A |
|
60
|
|
|
* |
|
61
|
|
|
* @throws \InvalidArgumentException |
|
62
|
|
|
* |
|
63
|
|
|
* @param string $host A string representing a URI fragment |
|
64
|
|
|
*/ |
|
65
|
7 |
|
public function __construct($host) |
|
66
|
|
|
{ |
|
67
|
7 |
|
parent::__construct($host, "Host"); |
|
68
|
1 |
|
} |
|
69
|
|
|
} |
|
70
|
|
|
|