1 | <?php |
||
22 | abstract class AbstractHttpProvider extends AbstractProvider |
||
23 | { |
||
24 | /** |
||
25 | * @var HttpClient |
||
26 | */ |
||
27 | private $client; |
||
28 | |||
29 | /** |
||
30 | * @var MessageFactory |
||
31 | */ |
||
32 | private $messageFactory; |
||
33 | |||
34 | /** |
||
35 | * AbstractHttpProvider Constructor. |
||
36 | * |
||
37 | * @param HttpClient $client HttpClient makes HTTP requests. |
||
38 | * @param MessageFactory $messageFactory MessageFactory creates Request objects. |
||
39 | */ |
||
40 | public function __construct(HttpClient $client = null, MessageFactory $messageFactory = null) |
||
54 | |||
55 | /** |
||
56 | * Returns a ResponseInterface for the given URI/method. |
||
57 | * |
||
58 | * @param string|UriInterface $uri Request URI. |
||
59 | * @param string $method HTTP method (Defaults to 'GET'). |
||
60 | * |
||
61 | * @return ResponseInterface |
||
62 | */ |
||
63 | protected function getResponse($uri, $method = 'GET') |
||
69 | |||
70 | /** |
||
71 | * @param string|float $lat Coordinate latitude. |
||
72 | * @param string|float $lng Coordinate longitude. |
||
73 | * @param int|null $timestamp Seconds since Jan 1, 1970 UTC. |
||
74 | * |
||
75 | * @throws RuntimeException When the response body cannot be decoded. |
||
76 | * |
||
77 | * @return object |
||
78 | */ |
||
79 | protected function getResult($lat, $lng, $timestamp = null) |
||
92 | |||
93 | /** |
||
94 | * Returns the URI for the specified location and timestamp. |
||
95 | * |
||
96 | * @param string|float $lat Coordinate latitude. |
||
97 | * @param string|float $lng Coordinate longitude. |
||
98 | * @param int|null $timestamp Seconds since Jan 1, 1970 UTC. |
||
99 | * |
||
100 | * @return string|UriInterface |
||
101 | */ |
||
102 | abstract protected function buildUri($lat, $lng, $timestamp = null); |
||
103 | } |
||
104 |