1 | <?php |
||
25 | class HttpClient |
||
26 | { |
||
27 | /** |
||
28 | * HTTP client for requests to the application. |
||
29 | * |
||
30 | * @var PhpHttpClient |
||
31 | */ |
||
32 | private $httpClient; |
||
33 | |||
34 | /** |
||
35 | * @var string |
||
36 | */ |
||
37 | private $hostname; |
||
38 | |||
39 | /** |
||
40 | * @var string |
||
41 | */ |
||
42 | private $port; |
||
43 | |||
44 | /** |
||
45 | * @param string $hostname Default hostname if not specified in the URL |
||
46 | * @param string $port Default port if not specified in the URL |
||
47 | */ |
||
48 | 33 | public function __construct($hostname, $port) |
|
53 | |||
54 | /** |
||
55 | * Get HTTP response from your application. |
||
56 | * |
||
57 | * @param string $uri HTTP URI |
||
58 | * @param array $headers HTTP headers |
||
59 | * @param string $method HTTP method |
||
60 | * |
||
61 | * @return ResponseInterface |
||
62 | */ |
||
63 | 33 | public function getResponse($uri, array $headers, $method) |
|
69 | |||
70 | /** |
||
71 | * Send HTTP request to your application. |
||
72 | * |
||
73 | * @param RequestInterface $request |
||
74 | * |
||
75 | * @return ResponseInterface |
||
76 | */ |
||
77 | 33 | public function sendRequest(RequestInterface $request) |
|
85 | |||
86 | /** |
||
87 | * Get HTTP client for your application. |
||
88 | * |
||
89 | * @return PhpHttpClient |
||
90 | */ |
||
91 | 33 | private function getHttpClient() |
|
99 | |||
100 | /** |
||
101 | * Create a request. |
||
102 | * |
||
103 | * @param string $method |
||
104 | * @param string $uri |
||
105 | * @param array $headers |
||
106 | * |
||
107 | * @return RequestInterface |
||
108 | * |
||
109 | * @throws \Exception |
||
110 | */ |
||
111 | 33 | private function createRequest($method, $uri, $headers) |
|
133 | |||
134 | /** |
||
135 | * Create PSR-7 URI object from URI string. |
||
136 | * |
||
137 | * @param string $uriString |
||
138 | * |
||
139 | * @return UriInterface |
||
140 | */ |
||
141 | 33 | private function createUri($uriString) |
|
145 | } |
||
146 |
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: