| 1 | <?php |
||
| 5 | class Geocoder |
||
| 6 | { |
||
| 7 | const API_URL = 'http://maps.google.com/maps/api/geocode'; |
||
| 8 | const VALID_OUTPUT_FORMAT = ['json', 'xml']; |
||
| 9 | |||
| 10 | /** |
||
| 11 | * @param $address |
||
| 12 | * @param string $region |
||
| 13 | * @param string $outputFormat |
||
| 14 | * |
||
| 15 | * @return string |
||
| 16 | * @throws \Exception |
||
| 17 | */ |
||
| 18 | 6 | public function geocode($address, $region = '', $outputFormat = 'json') |
|
| 26 | |||
| 27 | /** |
||
| 28 | * @param $address |
||
| 29 | * |
||
| 30 | * @return array |
||
| 31 | */ |
||
| 32 | 3 | public function getLatLng($address) |
|
| 51 | |||
| 52 | /** |
||
| 53 | * @param $format |
||
| 54 | * |
||
| 55 | * @return bool |
||
| 56 | */ |
||
| 57 | 6 | private function validateOutputFormat($format) |
|
| 65 | |||
| 66 | /** |
||
| 67 | * @param $address |
||
| 68 | * @param string $region |
||
| 69 | * @param string $outputFormat |
||
| 70 | * @param bool $sensor |
||
| 71 | * |
||
| 72 | * @return string |
||
| 73 | */ |
||
| 74 | 6 | private function generateRequestUrl($address, $region = '', $outputFormat = 'json', $sensor = false) |
|
| 84 | } |
||
| 85 |