| 1 | <?php |
||
| 10 | abstract class HttpClient |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @var Client Client HTTP. |
||
| 14 | */ |
||
| 15 | protected $httpClient; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * Client constructor. |
||
| 19 | * |
||
| 20 | * @param Client $httpClient |
||
| 21 | */ |
||
| 22 | 9 | public function __construct(Client $httpClient = null) |
|
| 23 | { |
||
| 24 | 9 | $this->httpClient = $httpClient ?: HttpClientDiscovery::find(); |
|
| 25 | 9 | } |
|
| 26 | |||
| 27 | /** |
||
| 28 | * Send GET HTTP to a given endpoint. |
||
| 29 | * |
||
| 30 | * @param null|string $uri |
||
| 31 | * |
||
| 32 | * @return \Psr\Http\Message\StreamInterface |
||
| 33 | */ |
||
| 34 | 6 | public function get($uri = null) |
|
| 35 | { |
||
| 36 | 6 | $request = new Request('GET', $uri); |
|
| 37 | |||
| 38 | 6 | return $this->httpClient->sendRequest($request)->getBody(); |
|
| 39 | } |
||
| 40 | |||
| 41 | abstract public function getLatLong(Address $address); |
||
| 42 | } |
||
| 43 |