/**
* usage e.g.
* ```
* use \dbsparkleTeam\unispot\formatters\AddressFormatter;
* use \dbsparkleTeam\unispot\components\Location;
*
* Location::getAddress(60.023554,30.2232882,[
* 'type' => AddressFormatter::TYPE_FULL,
* 'format' => AddressFormatter::FORMAT_NORMAL
* ])
* ```
* @param float $lat
* @param float $lng
* @param array $options
* @return string
*/
public static function getAddress($lat, $lng, $options = [])
{
$curl = new CurlHttpAdapter();
$geocoder = new GoogleMaps($curl);
$addressData = $geocoder->reverse($lat, $lng);
if (!isset($options['format']) || !in_array($options['format'], [AddressFormatter::FORMAT_NORMAL, AddressFormatter::FORMAT_REVERSED])) {
$options['format'] = AddressFormatter::FORMAT_NORMAL;
}
if (!isset($options['type']) || !in_array($options['type'], [AddressFormatter::TYPE_FULL, AddressFormatter::TYPE_SHORT])) {
$options['type'] = AddressFormatter::TYPE_FULL;
}
return AddressFormatter::format($addressData->first(), $options);
}