Conditions | 1 |
Paths | 1 |
Total Lines | 23 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
12 | public function getAddressFromZipcode($zipCode) |
||
13 | 4 | { |
|
14 | $zipCode = preg_replace('/[^0-9]/im', '', $zipCode); |
||
15 | |||
16 | 4 | $headers = [ |
|
17 | "Accept" => "application/json", |
||
18 | ]; |
||
19 | 4 | ||
20 | $client = new Client(['base_uri' => "{$this->endPoint}/{$zipCode}/"]); |
||
21 | 4 | ||
22 | 4 | $response = $client->get( |
|
23 | 'json', |
||
24 | 4 | [ |
|
25 | 4 | 'headers' => $headers, |
|
26 | 'connect_timeout' => 5, // seconds |
||
27 | 'debug' => false, |
||
28 | ] |
||
29 | ); |
||
30 | 4 | ||
31 | 4 | $response = $response->getBody()->getContents(); |
|
32 | $response = json_decode($response); |
||
33 | 4 | ||
34 | return $this->normalizeResponse((array)$response); |
||
35 | } |
||
60 |