geocoder-php/Geocoder — pull request #357 by MattKetmo (2014-10-28 10:41:54+00:00)
Title: [RFC] Make Provider extends Geocoder

One thing I'm not sure to understand is why there are both `Geocoder` and `Provider` interfaces.

Those 2 interfaces are almost identical (`geocode()` vs `getGeocodedData()` / `reverse` vs `getReversedData()`) and then bring no real value.

What I'm suggesting here is to make the `Provider`s extending the `Geocoder`s. Thus the `ProviderBasedGeocoder` just acts as an aggregator and each provider can be used individually as a valid `Geocoder` instance.

It facilitates the use of specific provider options and then it allows to bypass the level of abstraction I described at https://github.com/geocoder-php/Geocoder/issues/322#issuecomment-58175915, which is for me the most blocking thing that prevent me from using this lib correctly.

In this PR I only fixed the GoogleMaps provider for the demo, and add a `setRegion()` method to it:

```php
$adapter = new Ivory\HttpAdapter\CurlHttpAdapter();
$geocoder = new Geocoder\Provider\GoogleMaps($adapter);

$data = $geocoder->geocode('Toledo');
echo $data[0]->getCountry()->getCode(); // US

$geocoder->setRegion('ES');
$data = $geocoder->geocode('Toledo');
echo $data[0]->getCountry()->getCode(); // ES
```

Let me know what you think about it.