1 | <?php |
||
13 | class Geocode |
||
14 | { |
||
15 | /** |
||
16 | * API URL through which the address will be obtained. |
||
17 | */ |
||
18 | private $serviceUrl = "://maps.googleapis.com/maps/api/geocode/json?"; |
||
19 | |||
20 | /** |
||
21 | * Array containing the query results |
||
22 | */ |
||
23 | private $serviceResults; |
||
24 | |||
25 | /** |
||
26 | * Constructor |
||
27 | * |
||
28 | * @param string $key Google Maps Geocoding API key |
||
29 | */ |
||
30 | 6 | public function __construct($key = '') |
|
36 | |||
37 | /** |
||
38 | * Returns the private $serviceUrl |
||
39 | * |
||
40 | * @return string The service URL |
||
41 | */ |
||
42 | 5 | public function getServiceUrl() |
|
46 | |||
47 | /** |
||
48 | * Sends request to the passed Google Geocode API URL and fetches the address details and returns them |
||
49 | * |
||
50 | * @param $address |
||
51 | * |
||
52 | * @return bool|object false if no data is returned by URL and the detail otherwise |
||
53 | * @throws \Exception |
||
54 | * @internal param string $url Google geocode API URL containing the address or latitude/longitude |
||
55 | */ |
||
56 | 4 | public function get($address) |
|
77 | } |
||
78 |