|
4 | 4 | use GuzzleHttp\Client; |
5 | 5 | use GuzzleHttp\Exception\BadResponseException; |
6 | 6 |
|
7 | | -class GuzzleFeatureRequester implements FeatureRequester |
8 | | -{ |
9 | | - function __construct($baseUri, $apiKey, $options) |
10 | | - { |
11 | | - $this->_client = new Client(array( |
12 | | - 'base_uri' => $baseUri, |
13 | | - 'headers' => array( |
14 | | - 'Authorization' => "api_key {$apiKey}", |
15 | | - 'Content-Type' => 'application/json', |
16 | | - 'User-Agent' => 'PHPClient/' . LDClient::VERSION |
17 | | - ), |
18 | | - 'debug' => false, |
19 | | - 'timeout' => $options['timeout'], |
20 | | - 'connect_timeout' => $options['connect_timeout'] |
21 | | - )); |
22 | | - } |
23 | | - |
24 | | - /** |
25 | | - * Gets feature data from a likely cached store |
26 | | - * |
27 | | - * @param $key string feature key |
28 | | - * @return array|null The decoded JSON feature data, or null if missing |
29 | | - */ |
30 | | - public function get($key) |
31 | | - { |
32 | | - try { |
33 | | - $response = $this->_client->get("/api/eval/features/$key"); |
34 | | - return json_decode($response->getBody(), true); |
35 | | - } catch (BadResponseException $e) { |
36 | | - $code = $e->getResponse()->getStatusCode(); |
37 | | - error_log("GuzzleFeatureRetriever::get received an unexpected HTTP status code $code"); |
38 | | - return null; |
39 | | - } |
40 | | - } |
41 | | -}<?php |
42 | | -namespace LaunchDarkly; |
43 | | - |
44 | | -use GuzzleHttp\Client; |
45 | | -use GuzzleHttp\Exception\BadResponseException; |
46 | | - |
47 | | -class GuzzleFeatureRequester implements FeatureRequester |
48 | | -{ |
49 | | - function __construct($baseUri, $apiKey, $options) |
50 | | - { |
51 | | - $this->_client = new Client(array( |
52 | | - 'base_uri' => $baseUri, |
53 | | - 'headers' => array( |
54 | | - 'Authorization' => "api_key {$apiKey}", |
55 | | - 'Content-Type' => 'application/json', |
56 | | - 'User-Agent' => 'PHPClient/' . LDClient::VERSION |
57 | | - ), |
58 | | - 'debug' => false, |
59 | | - 'timeout' => $options['timeout'], |
60 | | - 'connect_timeout' => $options['connect_timeout'] |
61 | | - )); |
62 | | - } |
63 | | - |
64 | | - /** |
65 | | - * Gets feature data from a likely cached store |
66 | | - * |
67 | | - * @param $key string feature key |
68 | | - * @return array|null The decoded JSON feature data, or null if missing |
69 | | - */ |
70 | | - public function get($key) |
71 | | - { |
72 | | - try { |
73 | | - $response = $this->_client->get("/api/eval/features/$key"); |
74 | | - return json_decode($response->getBody(), true); |
75 | | - } catch (BadResponseException $e) { |
76 | | - $code = $e->getResponse()->getStatusCode(); |
77 | | - error_log("GuzzleFeatureRetriever::get received an unexpected HTTP status code $code"); |
78 | | - return null; |
79 | | - } |
80 | | - } |
81 | | -}<?php |
82 | | -namespace LaunchDarkly; |
83 | | - |
84 | | -use GuzzleHttp\Client; |
85 | | -use GuzzleHttp\Exception\BadResponseException; |
86 | | - |
87 | | -class GuzzleFeatureRequester implements FeatureRequester |
88 | | -{ |
89 | | - function __construct($baseUri, $apiKey, $options) |
90 | | - { |
91 | | - $this->_client = new Client(array( |
92 | | - 'base_uri' => $baseUri, |
93 | | - 'headers' => array( |
94 | | - 'Authorization' => "api_key {$apiKey}", |
95 | | - 'Content-Type' => 'application/json', |
96 | | - 'User-Agent' => 'PHPClient/' . LDClient::VERSION |
97 | | - ), |
98 | | - 'debug' => false, |
99 | | - 'timeout' => $options['timeout'], |
100 | | - 'connect_timeout' => $options['connect_timeout'] |
101 | | - )); |
102 | | - } |
103 | | - |
104 | | - /** |
105 | | - * Gets feature data from a likely cached store |
106 | | - * |
107 | | - * @param $key string feature key |
108 | | - * @return array|null The decoded JSON feature data, or null if missing |
109 | | - */ |
110 | | - public function get($key) |
111 | | - { |
112 | | - try { |
113 | | - $response = $this->_client->get("/api/eval/features/$key"); |
114 | | - return json_decode($response->getBody(), true); |
115 | | - } catch (BadResponseException $e) { |
116 | | - $code = $e->getResponse()->getStatusCode(); |
117 | | - error_log("GuzzleFeatureRetriever::get received an unexpected HTTP status code $code"); |
118 | | - return null; |
119 | | - } |
120 | | - } |
121 | | -}<?php |
122 | | -namespace LaunchDarkly; |
123 | | - |
124 | | -use GuzzleHttp\Client; |
125 | | -use GuzzleHttp\Exception\BadResponseException; |
126 | | - |
127 | | -class GuzzleFeatureRequester implements FeatureRequester |
128 | | -{ |
129 | | - function __construct($baseUri, $apiKey, $options) |
130 | | - { |
131 | | - $this->_client = new Client(array( |
132 | | - 'base_uri' => $baseUri, |
133 | | - 'headers' => array( |
134 | | - 'Authorization' => "api_key {$apiKey}", |
135 | | - 'Content-Type' => 'application/json', |
136 | | - 'User-Agent' => 'PHPClient/' . LDClient::VERSION |
137 | | - ), |
138 | | - 'debug' => false, |
139 | | - 'timeout' => $options['timeout'], |
140 | | - 'connect_timeout' => $options['connect_timeout'] |
141 | | - )); |
142 | | - } |
143 | | - |
144 | | - /** |
145 | | - * Gets feature data from a likely cached store |
146 | | - * |
147 | | - * @param $key string feature key |
148 | | - * @return array|null The decoded JSON feature data, or null if missing |
149 | | - */ |
150 | | - public function get($key) |
151 | | - { |
152 | | - try { |
153 | | - $response = $this->_client->get("/api/eval/features/$key"); |
154 | | - return json_decode($response->getBody(), true); |
155 | | - } catch (BadResponseException $e) { |
156 | | - $code = $e->getResponse()->getStatusCode(); |
157 | | - error_log("GuzzleFeatureRetriever::get received an unexpected HTTP status code $code"); |
158 | | - return null; |
159 | | - } |
160 | | - } |
161 | | -}<?php |
162 | | -namespace LaunchDarkly; |
163 | | - |
164 | | -use GuzzleHttp\Client; |
165 | | -use GuzzleHttp\Exception\BadResponseException; |
166 | | - |
167 | | -class GuzzleFeatureRequester implements FeatureRequester |
168 | | -{ |
169 | | - function __construct($baseUri, $apiKey, $options) |
170 | | - { |
171 | | - $this->_client = new Client(array( |
172 | | - 'base_uri' => $baseUri, |
173 | | - 'headers' => array( |
174 | | - 'Authorization' => "api_key {$apiKey}", |
175 | | - 'Content-Type' => 'application/json', |
176 | | - 'User-Agent' => 'PHPClient/' . LDClient::VERSION |
177 | | - ), |
178 | | - 'debug' => false, |
179 | | - 'timeout' => $options['timeout'], |
180 | | - 'connect_timeout' => $options['connect_timeout'] |
181 | | - )); |
182 | | - } |
183 | | - |
184 | | - /** |
185 | | - * Gets feature data from a likely cached store |
186 | | - * |
187 | | - * @param $key string feature key |
188 | | - * @return array|null The decoded JSON feature data, or null if missing |
189 | | - */ |
190 | | - public function get($key) |
191 | | - { |
192 | | - try { |
193 | | - $response = $this->_client->get("/api/eval/features/$key"); |
194 | | - return json_decode($response->getBody(), true); |
195 | | - } catch (BadResponseException $e) { |
196 | | - $code = $e->getResponse()->getStatusCode(); |
197 | | - error_log("GuzzleFeatureRetriever::get received an unexpected HTTP status code $code"); |
198 | | - return null; |
199 | | - } |
200 | | - } |
201 | | -}<?php |
202 | | -namespace LaunchDarkly; |
203 | | - |
204 | | -use GuzzleHttp\Client; |
205 | | -use GuzzleHttp\Exception\BadResponseException; |
206 | | - |
207 | | -class GuzzleFeatureRequester implements FeatureRequester |
208 | | -{ |
209 | | - function __construct($baseUri, $apiKey, $options) |
210 | | - { |
211 | | - $this->_client = new Client(array( |
212 | | - 'base_uri' => $baseUri, |
213 | | - 'headers' => array( |
214 | | - 'Authorization' => "api_key {$apiKey}", |
215 | | - 'Content-Type' => 'application/json', |
216 | | - 'User-Agent' => 'PHPClient/' . LDClient::VERSION |
217 | | - ), |
218 | | - 'debug' => false, |
219 | | - 'timeout' => $options['timeout'], |
220 | | - 'connect_timeout' => $options['connect_timeout'] |
221 | | - )); |
222 | | - } |
223 | | - |
224 | | - /** |
225 | | - * Gets feature data from a likely cached store |
226 | | - * |
227 | | - * @param $key string feature key |
228 | | - * @return array|null The decoded JSON feature data, or null if missing |
229 | | - */ |
230 | | - public function get($key) |
231 | | - { |
232 | | - try { |
233 | | - $response = $this->_client->get("/api/eval/features/$key"); |
234 | | - return json_decode($response->getBody(), true); |
235 | | - } catch (BadResponseException $e) { |
236 | | - $code = $e->getResponse()->getStatusCode(); |
237 | | - error_log("GuzzleFeatureRetriever::get received an unexpected HTTP status code $code"); |
238 | | - return null; |
239 | | - } |
240 | | - } |
241 | | -}<?php |
242 | | -namespace LaunchDarkly; |
243 | | - |
244 | | -use GuzzleHttp\Client; |
245 | | -use GuzzleHttp\Exception\BadResponseException; |
246 | | - |
247 | | -class GuzzleFeatureRequester implements FeatureRequester |
248 | | -{ |
249 | | - function __construct($baseUri, $apiKey, $options) |
250 | | - { |
251 | | - $this->_client = new Client(array( |
252 | | - 'base_uri' => $baseUri, |
253 | | - 'headers' => array( |
254 | | - 'Authorization' => "api_key {$apiKey}", |
255 | | - 'Content-Type' => 'application/json', |
256 | | - 'User-Agent' => 'PHPClient/' . LDClient::VERSION |
257 | | - ), |
258 | | - 'debug' => false, |
259 | | - 'timeout' => $options['timeout'], |
260 | | - 'connect_timeout' => $options['connect_timeout'] |
261 | | - )); |
262 | | - } |
263 | | - |
264 | | - /** |
265 | | - * Gets feature data from a likely cached store |
266 | | - * |
267 | | - * @param $key string feature key |
268 | | - * @return array|null The decoded JSON feature data, or null if missing |
269 | | - */ |
270 | | - public function get($key) |
271 | | - { |
272 | | - try { |
273 | | - $response = $this->_client->get("/api/eval/features/$key"); |
274 | | - return json_decode($response->getBody(), true); |
275 | | - } catch (BadResponseException $e) { |
276 | | - $code = $e->getResponse()->getStatusCode(); |
277 | | - error_log("GuzzleFeatureRetriever::get received an unexpected HTTP status code $code"); |
278 | | - return null; |
279 | | - } |
280 | | - } |
281 | | -}<?php |
282 | | -namespace LaunchDarkly; |
283 | | - |
284 | | -use GuzzleHttp\Client; |
285 | | -use GuzzleHttp\Exception\BadResponseException; |
286 | | - |
287 | | -class GuzzleFeatureRequester implements FeatureRequester |
288 | | -{ |
289 | | - function __construct($baseUri, $apiKey, $options) |
290 | | - { |
291 | | - $this->_client = new Client(array( |
292 | | - 'base_uri' => $baseUri, |
293 | | - 'headers' => array( |
294 | | - 'Authorization' => "api_key {$apiKey}", |
295 | | - 'Content-Type' => 'application/json', |
296 | | - 'User-Agent' => 'PHPClient/' . LDClient::VERSION |
297 | | - ), |
298 | | - 'debug' => false, |
299 | | - 'timeout' => $options['timeout'], |
300 | | - 'connect_timeout' => $options['connect_timeout'] |
301 | | - )); |
302 | | - } |
303 | | - |
304 | | - /** |
305 | | - * Gets feature data from a likely cached store |
306 | | - * |
307 | | - * @param $key string feature key |
308 | | - * @return array|null The decoded JSON feature data, or null if missing |
309 | | - */ |
310 | | - public function get($key) |
311 | | - { |
312 | | - try { |
313 | | - $response = $this->_client->get("/api/eval/features/$key"); |
314 | | - return json_decode($response->getBody(), true); |
315 | | - } catch (BadResponseException $e) { |
316 | | - $code = $e->getResponse()->getStatusCode(); |
317 | | - error_log("GuzzleFeatureRetriever::get received an unexpected HTTP status code $code"); |
318 | | - return null; |
319 | | - } |
320 | | - } |
321 | | -}<?php |
322 | | -namespace LaunchDarkly; |
323 | | - |
324 | | -use GuzzleHttp\Client; |
325 | | -use GuzzleHttp\Exception\BadResponseException; |
326 | | - |
327 | 7 | class GuzzleFeatureRequester implements FeatureRequester |
328 | 8 | { |
329 | 9 | function __construct($baseUri, $apiKey, $options) |
|
0 commit comments