|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Zapheus\Bridge\Psr\Zapheus; |
|
4
|
|
|
|
|
5
|
|
|
use Psr\Http\Message\UriInterface; |
|
6
|
|
|
use Zapheus\Http\Message\Uri as AbstractUri; |
|
7
|
|
|
use Zapheus\Http\Message\UriInterface as ZapheusUriInterface; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* PSR-07 to Zapheus URI Bridge |
|
11
|
|
|
* |
|
12
|
|
|
* @package Zapheus |
|
13
|
|
|
* @author Rougin Royce Gutib <[email protected]> |
|
14
|
|
|
*/ |
|
15
|
|
|
class Uri extends AbstractUri implements ZapheusUriInterface |
|
16
|
|
|
{ |
|
17
|
|
|
/** |
|
18
|
|
|
* @var \Psr\Http\Message\UriInterface |
|
19
|
|
|
*/ |
|
20
|
|
|
protected $uri; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Initializes the URI instance. |
|
24
|
|
|
* |
|
25
|
|
|
* @param \Psr\Http\Message\UriInterface $uri |
|
26
|
|
|
*/ |
|
27
|
54 |
|
public function __construct(UriInterface $uri) |
|
28
|
|
|
{ |
|
29
|
54 |
|
$this->uri = $uri; |
|
30
|
54 |
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Return the string representation as a URI reference. |
|
34
|
|
|
* |
|
35
|
|
|
* @return string |
|
36
|
|
|
*/ |
|
37
|
3 |
|
public function __toString() |
|
38
|
|
|
{ |
|
39
|
3 |
|
return (string) $this->uri; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Returns the authority component of the URI. |
|
44
|
|
|
* |
|
45
|
|
|
* @return string |
|
46
|
|
|
*/ |
|
47
|
3 |
|
public function authority() |
|
48
|
|
|
{ |
|
49
|
3 |
|
return $this->uri->getAuthority(); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Returns the fragment component of the URI. |
|
54
|
|
|
* |
|
55
|
|
|
* @return string |
|
56
|
|
|
*/ |
|
57
|
3 |
|
public function fragment() |
|
58
|
|
|
{ |
|
59
|
3 |
|
return $this->uri->getFragment(); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* Returns the host component of the URI. |
|
64
|
|
|
* |
|
65
|
|
|
* @return string |
|
66
|
|
|
*/ |
|
67
|
3 |
|
public function host() |
|
68
|
|
|
{ |
|
69
|
3 |
|
return $this->uri->getHost(); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Returns the path component of the URI. |
|
74
|
|
|
* |
|
75
|
|
|
* @return string |
|
76
|
|
|
*/ |
|
77
|
3 |
|
public function path() |
|
78
|
|
|
{ |
|
79
|
3 |
|
return $this->uri->getPath(); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* Returns the port component of the URI. |
|
84
|
|
|
* |
|
85
|
|
|
* @return null|integer |
|
86
|
|
|
*/ |
|
87
|
3 |
|
public function port() |
|
88
|
|
|
{ |
|
89
|
3 |
|
return $this->uri->getPort(); |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* Returns the query string of the URI. |
|
94
|
|
|
* |
|
95
|
|
|
* @return string |
|
96
|
|
|
*/ |
|
97
|
3 |
|
public function query() |
|
98
|
|
|
{ |
|
99
|
3 |
|
return $this->uri->getQuery(); |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* Returns the scheme component of the URI. |
|
104
|
|
|
* |
|
105
|
|
|
* @return string |
|
106
|
|
|
*/ |
|
107
|
3 |
|
public function scheme() |
|
108
|
|
|
{ |
|
109
|
3 |
|
return $this->uri->getScheme(); |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
/** |
|
113
|
|
|
* Returns the user information component of the URI. |
|
114
|
|
|
* |
|
115
|
|
|
* @return string |
|
116
|
|
|
*/ |
|
117
|
3 |
|
public function user() |
|
118
|
|
|
{ |
|
119
|
3 |
|
return $this->uri->getUserInfo(); |
|
120
|
|
|
} |
|
121
|
|
|
} |
|
122
|
|
|
|