1 | <?php |
||
22 | class Request extends AbstractHttpMessage |
||
23 | { |
||
24 | const HTTP_1_1 = '1.1'; |
||
25 | /** |
||
26 | * @var string |
||
27 | */ |
||
28 | private $method; |
||
29 | |||
30 | /** |
||
31 | * @var string |
||
32 | */ |
||
33 | private $uri; |
||
34 | |||
35 | /** |
||
36 | * @var string |
||
37 | */ |
||
38 | private $host; |
||
39 | |||
40 | /** |
||
41 | * @var int |
||
42 | */ |
||
43 | private $port; |
||
44 | |||
45 | private function __construct() {} |
||
46 | |||
47 | /** |
||
48 | * @return Request |
||
49 | */ |
||
50 | 14 | private function setMethod($method) : Request |
|
56 | |||
57 | /** |
||
58 | * @param string $uri |
||
59 | * @return Request |
||
60 | */ |
||
61 | 14 | private function setUri(string $uri) : Request |
|
67 | |||
68 | /** |
||
69 | * @return string |
||
70 | */ |
||
71 | 9 | public function getUri() : string |
|
75 | |||
76 | /** |
||
77 | * @return string |
||
78 | */ |
||
79 | 6 | public function getMethod() : string |
|
83 | |||
84 | /** |
||
85 | * @return int |
||
86 | */ |
||
87 | 1 | public function getVersion() : int |
|
91 | |||
92 | /** |
||
93 | * @param int $version |
||
94 | * @return Request |
||
95 | */ |
||
96 | 4 | public function setVersion(int $version) : Request |
|
102 | |||
103 | /** |
||
104 | * @param string $key |
||
105 | * @return Request |
||
106 | */ |
||
107 | 4 | public function setKey(string $key) : Request |
|
113 | |||
114 | /** |
||
115 | * @return string|null |
||
116 | */ |
||
117 | 3 | public function getKey() |
|
121 | |||
122 | /** |
||
123 | * @param string $host |
||
124 | * @return self |
||
125 | */ |
||
126 | 4 | private function setHost(string $host) : Request |
|
132 | |||
133 | /** |
||
134 | * @param int $port |
||
135 | * @return Request |
||
136 | */ |
||
137 | 4 | public function setPort($port) |
|
143 | |||
144 | /** |
||
145 | * @return array |
||
146 | */ |
||
147 | 2 | public function getExtensions() : array |
|
182 | |||
183 | /** |
||
184 | * @return string |
||
185 | */ |
||
186 | 4 | public function getRequestAsString() : string |
|
202 | |||
203 | /** |
||
204 | * @return string |
||
205 | */ |
||
206 | public function __toString() |
||
210 | |||
211 | /** |
||
212 | * @param string $requestString |
||
213 | * @return Request |
||
214 | * @throws HttpException |
||
215 | */ |
||
216 | 13 | public static function create(string $requestString) |
|
232 | |||
233 | /** |
||
234 | * @param string $uri |
||
235 | * @param string $host |
||
236 | * @param int|null $port |
||
237 | * @return Request |
||
238 | */ |
||
239 | 4 | public static function createClientRequest(string $uri, string $host, int $port = null) |
|
256 | |||
257 | /** |
||
258 | * @param string $firstLine |
||
259 | * @param Request $request |
||
260 | * @throws HttpException |
||
261 | */ |
||
262 | 13 | protected static function initRequest(string $firstLine, Request $request) |
|
285 | } |
||
286 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
integer
values, zero is a special case, in particular the following results might be unexpected: