diff --git a/README.md b/README.md index bde958e06..e6ca21ba2 100644 --- a/README.md +++ b/README.md @@ -50,13 +50,13 @@ Read more about HTTPlug in [their docs](http://docs.php-http.org/en/latest/httpl ### Summary (Just give me the command) -To install Google Maps geocoder with Guzzle 6 you may run the following command: +To install Google Maps geocoder with Guzzle 7 you may run the following command: ```cmd -composer require geocoder-php/google-maps-provider php-http/guzzle6-adapter +composer require geocoder-php/google-maps-provider guzzlehttp/guzzle ``` -Or using the curl client (you'll need to provide a PSR7 implementation such as `nyholm/psr7` if not using guzzle) +Or using the curl client (you'll need to provide a PSR7 implementation such as `nyholm/psr7` if not using Guzzle) ```cmd composer require geocoder-php/google-maps-provider php-http/curl-client nyholm/psr7 @@ -81,13 +81,13 @@ We have a small cookbook where you can find examples on common use cases: ## Usage -In the code snippet below we use GoogleMaps and Guzzle6. +In the code snippet below we use GoogleMaps and Guzzle 7. ```php use Geocoder\Query\GeocodeQuery; use Geocoder\Query\ReverseQuery; -$httpClient = new \Http\Adapter\Guzzle6\Client(); +$httpClient = new \GuzzleHttp\Client(); $provider = new \Geocoder\Provider\GoogleMaps\GoogleMaps($httpClient, null, 'your-api-key'); $geocoder = new \Geocoder\StatefulGeocoder($provider, 'en'); @@ -203,13 +203,13 @@ when a provider returns a result. The result is returned by `GoogleMaps` because use Geocoder\Query\GeocodeQuery; $geocoder = new \Geocoder\ProviderAggregator(); -$adapter = new \Http\Adapter\Guzzle6\Client(); +$client = new \GuzzleHttp\Client(); $chain = new \Geocoder\Provider\Chain\Chain([ - new \Geocoder\Provider\FreeGeoIp\FreeGeoIp($adapter), - new \Geocoder\Provider\HostIp\HostIp($adapter), - new \Geocoder\Provider\GoogleMaps\GoogleMaps($adapter, 'France'), - new \Geocoder\Provider\BingMaps\BingMaps($adapter, ''), + new \Geocoder\Provider\FreeGeoIp\FreeGeoIp($client), + new \Geocoder\Provider\HostIp\HostIp($client), + new \Geocoder\Provider\GoogleMaps\GoogleMaps($client, 'France'), + new \Geocoder\Provider\BingMaps\BingMaps($client, ''), // ... ]); @@ -230,15 +230,15 @@ decide which provider to use later on. use Geocoder\Query\GeocodeQuery; use Geocoder\Query\ReverseQuery; -$adapter = new \Http\Adapter\Guzzle6\Client(); +$client = new \GuzzleHttp\Client(); $geocoder = new \Geocoder\ProviderAggregator(); $geocoder->registerProviders([ - new \Geocoder\Provider\GoogleMaps\GoogleMaps($adapter), - new \Geocoder\Provider\GoogleMaps\GoogleMapsBusiness($adapter, ''), - new \Geocoder\Provider\Yandex\Yandex($adapter), - new \Geocoder\Provider\MaxMind\MaxMind($adapter, ''), - new \Geocoder\Provider\ArcGISOnline\ArcGISOnline($adapter), + new \Geocoder\Provider\GoogleMaps\GoogleMaps($client), + new \Geocoder\Provider\GoogleMaps\GoogleMapsBusiness($client, ''), + new \Geocoder\Provider\Yandex\Yandex($client), + new \Geocoder\Provider\MaxMind\MaxMind($client, ''), + new \Geocoder\Provider\ArcGISOnline\ArcGISOnline($client), ]); $geocoder->registerProvider(new \Geocoder\Provider\Nominatim\Nominatim($adapter, 'https://your.nominatim.server')); diff --git a/composer.json b/composer.json index 0162835d4..df3e1cb32 100644 --- a/composer.json +++ b/composer.json @@ -19,11 +19,11 @@ "require": { "php": "^7.4 || ^8.0", "igorw/get-in": "^1.0", - "php-http/client-implementation": "^1.0", "php-http/discovery": "^1.4", - "php-http/httplug": "^2.2", "php-http/message-factory": "^1.0.2", "php-http/promise": "^1.0", + "psr/http-client": "^1.0", + "psr/http-client-implementation": "^1.0", "psr/http-message-implementation": "^1.0", "psr/log": "^1.0|^2.0|^3.0", "psr/simple-cache": "^1.0|^2.0|^3.0" diff --git a/docs/cookbook/cache.md b/docs/cookbook/cache.md index 50d93b9e9..545c8cdde 100644 --- a/docs/cookbook/cache.md +++ b/docs/cookbook/cache.md @@ -1,13 +1,13 @@ # Caching responses -Many of the APIs are not free so it is a good idea to cache the responses so you -are not paying for the same information twice. The caching is out of scope for this +Many of the APIs are not free so it is a good idea to cache the responses so you +are not paying for the same information twice. The caching is out of scope for this library but we will show you an example how to properly cache responses with the HTTPlug [cache plugin](http://php-http.readthedocs.io/en/latest/plugins/cache.html): ```php use Cache\Adapter\Redis\RedisCachePool; -use Http\Adapter\Guzzle6\Client as GuzzleClient; +use GuzzleHttp\Client as GuzzleClient; use Http\Client\Common\PluginClient; use Geocoder\Provider\GoogleMaps; @@ -23,8 +23,8 @@ $cachePlugin = new CachePlugin($pool, StreamFactoryDiscovery::find(), [ 'default_ttl' => null, 'cache_lifetime' => 86400*365 ]); - -$adapter = new GuzzleClient(); + +$adapter = new GuzzleClient(); $pluginClient = new PluginClient($adapter, [$cachePlugin]); // Get a geocoder diff --git a/docs/cookbook/http-client.md b/docs/cookbook/http-client.md index 9d3ca9155..5b7dcae9e 100644 --- a/docs/cookbook/http-client.md +++ b/docs/cookbook/http-client.md @@ -2,27 +2,25 @@ The Geocoder is decoupled from the HTTP client that sends the HTTP messages. This means that you are responsible for configuring the HTTP client. Usually the default configuration -is good enough but sometime you may want to do something differently. +is good enough but sometime you may want to do something differently. How you configure the client differs between different clients below are two examples, -one with [Guzzle6 client](https://github.com/guzzle/guzzle) and one with the +one with [Guzzle 7 client](https://github.com/guzzle/guzzle) and one with the [cURL client](https://github.com/php-http/curl-client). -## Guzzle6 +## Guzzle 7 ```php -use GuzzleHttp\Client as GuzzleClient; -use Http\Adapter\Guzzle6\Client; +use GuzzleHttp\Client; use Geocoder\Provider\GoogleMaps; $config = [ 'timeout' => 2.0, 'verify' => false, ]; -$guzzle = new GuzzleClient($config); -$adapter = new Client($guzzle); -$geocoder = new GoogleMaps($adapter); +$client = new Client($config); +$geocoder = new GoogleMaps($client); $geocoder->geocode(...); ``` @@ -35,13 +33,12 @@ use Http\Client\Curl\Client; use Geocoder\Provider\GoogleMaps; $options = [ - CURLOPT_CONNECTTIMEOUT => 2, + CURLOPT_CONNECTTIMEOUT => 2, CURLOPT_SSL_VERIFYPEER => false, ]; -$adapter = new Client(null, null, $options); -$geocoder = new GoogleMaps($adapter); +$client = new Client(null, null, $options); +$geocoder = new GoogleMaps($client); $geocoder->geocode(...); ``` - diff --git a/docs/cookbook/rate-limiting.md b/docs/cookbook/rate-limiting.md index 5110fc2be..c1bc399c2 100644 --- a/docs/cookbook/rate-limiting.md +++ b/docs/cookbook/rate-limiting.md @@ -20,9 +20,8 @@ $stack = \GuzzleHttp\HandlerStack::create(); $stack->push(\Spatie\GuzzleRateLimiterMiddleware\RateLimiterMiddleware::perSecond(1)); $httpClient = new \GuzzleHttp\Client(['handler' => $stack, 'timeout' => 30.0]); -$httpAdapter = new \Http\Adapter\Guzzle6\Client($httpClient); $psr6Cache = new \Cache\Adapter\PHPArray\ArrayCachePool(); -$provider = new \Geocoder\Provider\Nominatim\Nominatim($httpAdapter, 'https://nominatim.openstreetmap.org', 'Geocoder test'); +$provider = new \Geocoder\Provider\Nominatim\Nominatim($httpClient, 'https://nominatim.openstreetmap.org', 'Geocoder test'); $cachedProvider = new \Geocoder\Provider\Cache\ProviderCache($provider, $psr6Cache); $geocoder = new \Geocoder\StatefulGeocoder($cachedProvider, 'en'); diff --git a/src/Http/Provider/AbstractHttpProvider.php b/src/Http/Provider/AbstractHttpProvider.php index 9dcec3454..8a24fab10 100644 --- a/src/Http/Provider/AbstractHttpProvider.php +++ b/src/Http/Provider/AbstractHttpProvider.php @@ -18,7 +18,7 @@ use Geocoder\Provider\AbstractProvider; use Http\Message\MessageFactory; use Http\Discovery\MessageFactoryDiscovery; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; use Psr\Http\Message\RequestInterface; /** @@ -28,7 +28,7 @@ abstract class AbstractHttpProvider extends AbstractProvider { /** - * @var HttpClient + * @var ClientInterface */ private $client; @@ -38,10 +38,10 @@ abstract class AbstractHttpProvider extends AbstractProvider private $messageFactory; /** - * @param HttpClient $client + * @param ClientInterface $client * @param MessageFactory|null $factory */ - public function __construct(HttpClient $client, MessageFactory $factory = null) + public function __construct(ClientInterface $client, MessageFactory $factory = null) { $this->client = $client; $this->messageFactory = $factory ?: MessageFactoryDiscovery::find(); @@ -106,9 +106,9 @@ protected function getParsedResponse(RequestInterface $request): string /** * Returns the HTTP adapter. * - * @return HttpClient + * @return ClientInterface */ - protected function getHttpClient(): HttpClient + protected function getHttpClient(): ClientInterface { return $this->client; } diff --git a/src/Http/Tests/Provider/AbstractHttpProviderTest.php b/src/Http/Tests/Provider/AbstractHttpProviderTest.php index 8a5212482..7227af6d8 100644 --- a/src/Http/Tests/Provider/AbstractHttpProviderTest.php +++ b/src/Http/Tests/Provider/AbstractHttpProviderTest.php @@ -17,7 +17,7 @@ use Geocoder\Model\AddressCollection; use Geocoder\Query\GeocodeQuery; use Geocoder\Query\ReverseQuery; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; use Http\Mock\Client; use PHPUnit\Framework\TestCase; @@ -33,7 +33,7 @@ public function testHttpClientGetter() class DummyProvider extends AbstractHttpProvider { - public function getHttpClient(): HttpClient + public function getHttpClient(): ClientInterface { return parent::getHttpClient(); } diff --git a/src/Provider/AlgoliaPlaces/AlgoliaPlaces.php b/src/Provider/AlgoliaPlaces/AlgoliaPlaces.php index 43072411f..1a6d9e6a7 100644 --- a/src/Provider/AlgoliaPlaces/AlgoliaPlaces.php +++ b/src/Provider/AlgoliaPlaces/AlgoliaPlaces.php @@ -22,7 +22,7 @@ use Geocoder\Provider\Provider; use Geocoder\Query\GeocodeQuery; use Geocoder\Query\ReverseQuery; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; use Psr\Http\Message\RequestInterface; class AlgoliaPlaces extends AbstractHttpProvider implements Provider @@ -53,10 +53,10 @@ class AlgoliaPlaces extends AbstractHttpProvider implements Provider /** @var GeocodeQuery */ private $query; - /** @var HttpClient */ + /** @var ClientInterface */ private $client; - public function __construct(HttpClient $client, string $apiKey = null, string $appId = null) + public function __construct(ClientInterface $client, string $apiKey = null, string $appId = null) { parent::__construct($client); diff --git a/src/Provider/AlgoliaPlaces/README.md b/src/Provider/AlgoliaPlaces/README.md index ab9a681ea..48dd0ed40 100644 --- a/src/Provider/AlgoliaPlaces/README.md +++ b/src/Provider/AlgoliaPlaces/README.md @@ -9,7 +9,7 @@ [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE) This is the Algolia Places provider from the PHP Geocoder. This is a **READ ONLY** repository. See the -[main repo](https://github.com/geocoder-php/Geocoder) for information and documentation. +[main repo](https://github.com/geocoder-php/Geocoder) for information and documentation. ## Install @@ -34,11 +34,11 @@ You should set a locale on the query. If it is missing, results may not be as co use Geocoder\Query\GeocodeQuery; use Geocoder\Query\ReverseQuery; -$httpClient = new \Http\Adapter\Guzzle6\Client(); +$httpClient = new \GuzzleHttp\Client(); // Unauthenticated $provider = new \Geocoder\Provider\AlgoliaPlaces\AlgoliaPlaces($httpClient); -// Authenticated +// Authenticated $provider = new \Geocoder\Provider\AlgoliaPlaces\AlgoliaPlaces($httpClient, '', ''); $geocoder = new \Geocoder\StatefulGeocoder($provider, 'en'); @@ -48,5 +48,5 @@ $result = $geocoder->geocodeQuery(GeocodeQuery::create('Paris')->withLocale('fr- ## Contribute -Contributions are very welcome! Send a pull request to the [main repository](https://github.com/geocoder-php/Geocoder) or +Contributions are very welcome! Send a pull request to the [main repository](https://github.com/geocoder-php/Geocoder) or report any issues you find on the [issue tracker](https://github.com/geocoder-php/Geocoder/issues). diff --git a/src/Provider/AlgoliaPlaces/Tests/IntegrationTest.php b/src/Provider/AlgoliaPlaces/Tests/IntegrationTest.php index 9f394723d..aec24c383 100644 --- a/src/Provider/AlgoliaPlaces/Tests/IntegrationTest.php +++ b/src/Provider/AlgoliaPlaces/Tests/IntegrationTest.php @@ -21,8 +21,8 @@ use Geocoder\Model\Country; use Geocoder\Query\GeocodeQuery; use Geocoder\Query\ReverseQuery; -use Http\Client\HttpClient; -use Http\Discovery\HttpClientDiscovery; +use Http\Discovery\Psr18ClientDiscovery; +use Psr\Http\Client\ClientInterface; /** * @author Sébastien Barré @@ -35,7 +35,7 @@ class IntegrationTest extends ProviderIntegrationTest protected $testReverse = false; - protected function createProvider(HttpClient $httpClient) + protected function createProvider(ClientInterface $httpClient) { return new AlgoliaPlaces($httpClient, $this->getApiKey(), $this->getAppId()); } @@ -53,9 +53,9 @@ protected function getCacheDir() private function getCachedHttpClient() { try { - $client = HttpClientDiscovery::find(); - } catch (\Http\Discovery\NotFoundException $e) { - $client = $this->getMockForAbstractClass(HttpClient::class); + $client = Psr18ClientDiscovery::find(); + } catch (\Http\Discovery\Exception\NotFoundException $e) { + $client = $this->getMockForAbstractClass(ClientInterface::class); $client ->expects($this->any()) diff --git a/src/Provider/ArcGISOnline/ArcGISOnline.php b/src/Provider/ArcGISOnline/ArcGISOnline.php index 71d36d3c3..6598fb02c 100644 --- a/src/Provider/ArcGISOnline/ArcGISOnline.php +++ b/src/Provider/ArcGISOnline/ArcGISOnline.php @@ -23,7 +23,7 @@ use Geocoder\Query\ReverseQuery; use Geocoder\Http\Provider\AbstractHttpProvider; use Geocoder\Provider\Provider; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author ALKOUM Dorian @@ -62,14 +62,14 @@ final class ArcGISOnline extends AbstractHttpProvider implements Provider * ArcGIS World Geocoding Service. * https://developers.arcgis.com/rest/geocode/api-reference/overview-world-geocoding-service.htm. * - * @param HttpClient $client An HTTP adapter - * @param string $token Your authentication token - * @param string $sourceCountry Country biasing (optional) + * @param ClientInterface $client An HTTP adapter + * @param string $token Your authentication token + * @param string $sourceCountry Country biasing (optional) * * @return ArcGISOnline */ public static function token( - HttpClient $client, + ClientInterface $client, string $token, string $sourceCountry = null ) { @@ -79,12 +79,12 @@ public static function token( } /** - * @param HttpClient $client An HTTP adapter - * @param string $sourceCountry Country biasing (optional) - * @param string $token ArcGIS World Geocoding Service token - * Required for the geocodeAddresses endpoint + * @param ClientInterface $client An HTTP adapter + * @param string $sourceCountry Country biasing (optional) + * @param string $token ArcGIS World Geocoding Service token + * Required for the geocodeAddresses endpoint */ - public function __construct(HttpClient $client, string $sourceCountry = null, string $token = null) + public function __construct(ClientInterface $client, string $sourceCountry = null, string $token = null) { parent::__construct($client); diff --git a/src/Provider/ArcGISOnline/Readme.md b/src/Provider/ArcGISOnline/Readme.md index 34c4f82e4..5586b8b3d 100644 --- a/src/Provider/ArcGISOnline/Readme.md +++ b/src/Provider/ArcGISOnline/Readme.md @@ -33,7 +33,7 @@ Since a token is required for the `geocodeAddresses` API, the ### Without a token ```php -$httpClient = new \Http\Adapter\Guzzle6\Client(); +$httpClient = new \GuzzleHttp\Client(); $provider = new \Geocoder\Provider\ArcGISList\ArcGISList($httpClient); @@ -45,7 +45,7 @@ $result = $geocoder->geocodeQuery(GeocodeQuery::create('Buckingham Palace, Londo ```php -$httpClient = new \Http\Adapter\Guzzle6\Client(); +$httpClient = new \GuzzleHttp\Client(); // Your token is required. $provider = \Geocoder\Provider\ArcGISList\ArcGISList::token($httpClient, 'your-token'); diff --git a/src/Provider/ArcGISOnline/Tests/IntegrationTest.php b/src/Provider/ArcGISOnline/Tests/IntegrationTest.php index cd4fd8911..0d7885cfb 100644 --- a/src/Provider/ArcGISOnline/Tests/IntegrationTest.php +++ b/src/Provider/ArcGISOnline/Tests/IntegrationTest.php @@ -14,7 +14,7 @@ use Geocoder\IntegrationTest\ProviderIntegrationTest; use Geocoder\Provider\ArcGISOnline\ArcGISOnline; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author Tobias Nyholm @@ -29,7 +29,7 @@ class IntegrationTest extends ProviderIntegrationTest 'testReverseQueryWithNoResults' => 'ArcGIS REST API returns "אצטדיון כדורגל עירוני" for reverse query at 0,0.', ]; - protected function createProvider(HttpClient $httpClient) + protected function createProvider(ClientInterface $httpClient) { return new ArcGISOnline($httpClient); } diff --git a/src/Provider/AzureMaps/AzureMaps.php b/src/Provider/AzureMaps/AzureMaps.php index b6c2b3dfe..1020cd11e 100644 --- a/src/Provider/AzureMaps/AzureMaps.php +++ b/src/Provider/AzureMaps/AzureMaps.php @@ -20,7 +20,7 @@ use Geocoder\Provider\Provider; use Geocoder\Query\GeocodeQuery; use Geocoder\Query\ReverseQuery; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; use stdClass; /** @@ -69,7 +69,7 @@ class AzureMaps extends AbstractHttpProvider implements Provider * AzureMaps constructor. */ public function __construct( - HttpClient $client, + ClientInterface $client, string $subscriptionKey, array $options = [], string $format = 'json' diff --git a/src/Provider/AzureMaps/README.md b/src/Provider/AzureMaps/README.md index 2b715f90f..3afbb7086 100644 --- a/src/Provider/AzureMaps/README.md +++ b/src/Provider/AzureMaps/README.md @@ -8,7 +8,7 @@ [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE) This is the Bing Maps provider from the PHP Geocoder. This is a **READ ONLY** repository. See the -[main repo](https://github.com/geocoder-php/Geocoder) for information and documentation. +[main repo](https://github.com/geocoder-php/Geocoder) for information and documentation. ## Install @@ -19,7 +19,7 @@ composer require geocoder-php/azure-maps-provider ## Usage ```php -$httpClient = new \Http\Adapter\Guzzle6\Client(); +$httpClient = new \GuzzleHttp\Client(); // You must provide a subscription key $provider = new \Geocoder\Provider\AzureMaps\AzureMaps($httpClient, 'your-subscription-key'); @@ -29,7 +29,7 @@ $result = $geocoder->geocodeQuery(GeocodeQuery::create('Yehuda Hamaccabi 15, Tel ## Contribute -Contributions are very welcome! Send a pull request to the [main repository](https://github.com/geocoder-php/Geocoder) or +Contributions are very welcome! Send a pull request to the [main repository](https://github.com/geocoder-php/Geocoder) or report any issues you find on the [issue tracker](https://github.com/geocoder-php/Geocoder/issues). diff --git a/src/Provider/AzureMaps/Tests/IntegrationTest.php b/src/Provider/AzureMaps/Tests/IntegrationTest.php index 06a36b014..60756015a 100644 --- a/src/Provider/AzureMaps/Tests/IntegrationTest.php +++ b/src/Provider/AzureMaps/Tests/IntegrationTest.php @@ -9,6 +9,7 @@ */ use Geocoder\IntegrationTest\ProviderIntegrationTest; +use Psr\Http\Client\ClientInterface; class IntegrationTest extends ProviderIntegrationTest { @@ -19,7 +20,7 @@ class IntegrationTest extends ProviderIntegrationTest /** * @return \Geocoder\Provider\Provider that is used in the tests */ - protected function createProvider(Http\Client\HttpClient $httpClient) + protected function createProvider(ClientInterface $httpClient) { return new \Geocoder\Provider\AzureMaps\AzureMaps($httpClient, $_SERVER['AZURE_MAPS_SUBSCRIPTION_KEY']); } diff --git a/src/Provider/BingMaps/BingMaps.php b/src/Provider/BingMaps/BingMaps.php index 3b371d1a3..1599340ad 100644 --- a/src/Provider/BingMaps/BingMaps.php +++ b/src/Provider/BingMaps/BingMaps.php @@ -21,7 +21,7 @@ use Geocoder\Query\ReverseQuery; use Geocoder\Http\Provider\AbstractHttpProvider; use Geocoder\Provider\Provider; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author David Guyon @@ -44,10 +44,10 @@ final class BingMaps extends AbstractHttpProvider implements Provider private $apiKey; /** - * @param HttpClient $client An HTTP adapter - * @param string $apiKey An API key + * @param ClientInterface $client An HTTP adapter + * @param string $apiKey An API key */ - public function __construct(HttpClient $client, string $apiKey) + public function __construct(ClientInterface $client, string $apiKey) { if (empty($apiKey)) { throw new InvalidCredentials('No API key provided.'); diff --git a/src/Provider/BingMaps/Tests/IntegrationTest.php b/src/Provider/BingMaps/Tests/IntegrationTest.php index 10b1afe7f..8eaa15cad 100644 --- a/src/Provider/BingMaps/Tests/IntegrationTest.php +++ b/src/Provider/BingMaps/Tests/IntegrationTest.php @@ -12,7 +12,7 @@ use Geocoder\IntegrationTest\ProviderIntegrationTest; use Geocoder\Provider\BingMaps\BingMaps; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author Tobias Nyholm @@ -27,7 +27,7 @@ class IntegrationTest extends ProviderIntegrationTest protected $testIpv6 = false; - protected function createProvider(HttpClient $httpClient) + protected function createProvider(ClientInterface $httpClient) { return new BingMaps($httpClient, $this->getApiKey()); } diff --git a/src/Provider/Cache/Readme.md b/src/Provider/Cache/Readme.md index fad7cf054..16f0e08e1 100644 --- a/src/Provider/Cache/Readme.md +++ b/src/Provider/Cache/Readme.md @@ -8,7 +8,7 @@ [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE) This is the a cache provider from the PHP Geocoder. This is a **READ ONLY** repository. See the -[main repo](https://github.com/geocoder-php/Geocoder) for information and documentation. +[main repo](https://github.com/geocoder-php/Geocoder) for information and documentation. ### Install @@ -20,11 +20,11 @@ composer require geocoder-php/cache-provider The `ProviderCache` allows you to use any [PSR-6](https://www.php-fig.org/psr/psr-6/) compatible cache driver. You can find compatible drivers on [packagist](https://packagist.org/providers/psr/cache-implementation). -By default, the result is cached forever. +By default, the result is cached forever. You can set a cache expiry by passing an integer representing the number of seconds as the third parameter. ```php -$httpClient = new \Http\Adapter\Guzzle6\Client(); +$httpClient = new \GuzzleHttp\Client(); $provider = new \Geocoder\Provider\GoogleMaps\GoogleMaps($httpClient); $psr6Cache = new ArrayCachePool(); // Requires `cache/array-adapter` package @@ -45,5 +45,5 @@ $result2 = $geocoder->geocodeQuery(GeocodeQuery::create('Buckingham Palace, Lond ### Contribute -Contributions are very welcome! Send a pull request to the [main repository](https://github.com/geocoder-php/Geocoder) or +Contributions are very welcome! Send a pull request to the [main repository](https://github.com/geocoder-php/Geocoder) or report any issues you find on the [issue tracker](https://github.com/geocoder-php/Geocoder/issues). diff --git a/src/Provider/FreeGeoIp/FreeGeoIp.php b/src/Provider/FreeGeoIp/FreeGeoIp.php index 94998e34a..da93ceef8 100644 --- a/src/Provider/FreeGeoIp/FreeGeoIp.php +++ b/src/Provider/FreeGeoIp/FreeGeoIp.php @@ -20,7 +20,7 @@ use Geocoder\Query\ReverseQuery; use Geocoder\Http\Provider\AbstractHttpProvider; use Geocoder\Provider\Provider; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author William Durand @@ -33,10 +33,10 @@ final class FreeGeoIp extends AbstractHttpProvider implements Provider private $baseUrl; /** - * @param HttpClient $client - * @param string $baseUrl + * @param ClientInterface $client + * @param string $baseUrl */ - public function __construct(HttpClient $client, string $baseUrl = 'https://freegeoip.app/json/%s') + public function __construct(ClientInterface $client, string $baseUrl = 'https://freegeoip.app/json/%s') { parent::__construct($client); diff --git a/src/Provider/FreeGeoIp/Readme.md b/src/Provider/FreeGeoIp/Readme.md index 6fdbc71e9..40b228758 100644 --- a/src/Provider/FreeGeoIp/Readme.md +++ b/src/Provider/FreeGeoIp/Readme.md @@ -8,17 +8,17 @@ [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE) This is the Free GeoIp provider from the PHP Geocoder. This is a **READ ONLY** repository. See the -[main repo](https://github.com/geocoder-php/Geocoder) for information and documentation. +[main repo](https://github.com/geocoder-php/Geocoder) for information and documentation. Provider Website: https://freegeoip.app ## Usage ```php -$httpClient = new \Http\Adapter\Guzzle6\Client(); +$httpClient = new \GuzzleHttp\Client(); // Use the default provider (https://freegeoip.app) $provider = new Geocoder\Provider\FreeGeoIp\FreeGeoIp($httpClient); -// Or provide the endpoint of your instance +// Or provide the endpoint of your instance $provider = new Geocoder\Provider\FreeGeoIp\FreeGeoIp($httpClient, 'http://my.internal.geocoder/json/%s'); ``` @@ -44,5 +44,5 @@ composer require geocoder-php/free-geoip-provider ## Contribute -Contributions are very welcome! Send a pull request to the [main repository](https://github.com/geocoder-php/Geocoder) or +Contributions are very welcome! Send a pull request to the [main repository](https://github.com/geocoder-php/Geocoder) or report any issues you find on the [issue tracker](https://github.com/geocoder-php/Geocoder/issues). diff --git a/src/Provider/FreeGeoIp/Tests/IntegrationTest.php b/src/Provider/FreeGeoIp/Tests/IntegrationTest.php index f4285cb38..e85852211 100644 --- a/src/Provider/FreeGeoIp/Tests/IntegrationTest.php +++ b/src/Provider/FreeGeoIp/Tests/IntegrationTest.php @@ -14,7 +14,7 @@ use Geocoder\IntegrationTest\ProviderIntegrationTest; use Geocoder\Provider\FreeGeoIp\FreeGeoIp; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author Tobias Nyholm @@ -25,7 +25,7 @@ class IntegrationTest extends ProviderIntegrationTest protected $testReverse = false; - protected function createProvider(HttpClient $httpClient) + protected function createProvider(ClientInterface $httpClient) { return new FreeGeoIp($httpClient); } diff --git a/src/Provider/GeoIP2/Tests/IntegrationTest.php b/src/Provider/GeoIP2/Tests/IntegrationTest.php index 6293f336a..e0cac8642 100644 --- a/src/Provider/GeoIP2/Tests/IntegrationTest.php +++ b/src/Provider/GeoIP2/Tests/IntegrationTest.php @@ -16,7 +16,7 @@ use Geocoder\Provider\GeoIP2\GeoIP2; use Geocoder\Provider\GeoIP2\GeoIP2Adapter; use GeoIp2\Database\Reader; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author Tobias Nyholm @@ -31,7 +31,7 @@ class IntegrationTest extends ProviderIntegrationTest protected $testHttpProvider = false; - protected function createProvider(HttpClient $httpClient) + protected function createProvider(ClientInterface $httpClient) { $reader = new Reader(__DIR__.'/fixtures/GeoLite2-City.mmdb'); diff --git a/src/Provider/GeoIPs/GeoIPs.php b/src/Provider/GeoIPs/GeoIPs.php index 7b112bdb8..15e2e5a28 100644 --- a/src/Provider/GeoIPs/GeoIPs.php +++ b/src/Provider/GeoIPs/GeoIPs.php @@ -24,7 +24,7 @@ use Geocoder\Query\ReverseQuery; use Geocoder\Http\Provider\AbstractHttpProvider; use Geocoder\Provider\Provider; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author Andrea Cristaudo @@ -62,10 +62,10 @@ final class GeoIPs extends AbstractHttpProvider implements Provider /** * @deprecated The GeoIPs provider has shut down * - * @param HttpClient $client An HTTP adapter - * @param string $apiKey An API key + * @param ClientInterface $client An HTTP adapter + * @param string $apiKey An API key */ - public function __construct(HttpClient $client, string $apiKey) + public function __construct(ClientInterface $client, string $apiKey) { if (empty($apiKey)) { throw new InvalidCredentials('No API key provided.'); diff --git a/src/Provider/GeoIPs/Tests/IntegrationTest.php b/src/Provider/GeoIPs/Tests/IntegrationTest.php index db5d0248a..729ade8a7 100644 --- a/src/Provider/GeoIPs/Tests/IntegrationTest.php +++ b/src/Provider/GeoIPs/Tests/IntegrationTest.php @@ -14,7 +14,7 @@ use Geocoder\IntegrationTest\ProviderIntegrationTest; use Geocoder\Provider\GeoIPs\GeoIPs; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author Tobias Nyholm @@ -27,7 +27,7 @@ class IntegrationTest extends ProviderIntegrationTest protected $testIpv6 = false; - protected function createProvider(HttpClient $httpClient) + protected function createProvider(ClientInterface $httpClient) { return new GeoIPs($httpClient, $this->getApiKey()); } diff --git a/src/Provider/GeoPlugin/Tests/IntegrationTest.php b/src/Provider/GeoPlugin/Tests/IntegrationTest.php index 104034c50..312ef851b 100644 --- a/src/Provider/GeoPlugin/Tests/IntegrationTest.php +++ b/src/Provider/GeoPlugin/Tests/IntegrationTest.php @@ -14,7 +14,7 @@ use Geocoder\IntegrationTest\ProviderIntegrationTest; use Geocoder\Provider\GeoPlugin\GeoPlugin; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author Tobias Nyholm @@ -25,7 +25,7 @@ class IntegrationTest extends ProviderIntegrationTest protected $testReverse = false; - protected function createProvider(HttpClient $httpClient) + protected function createProvider(ClientInterface $httpClient) { return new GeoPlugin($httpClient, $this->getApiKey()); } diff --git a/src/Provider/GeocodeEarth/GeocodeEarth.php b/src/Provider/GeocodeEarth/GeocodeEarth.php index 38d44f9be..c773a6953 100644 --- a/src/Provider/GeocodeEarth/GeocodeEarth.php +++ b/src/Provider/GeocodeEarth/GeocodeEarth.php @@ -18,7 +18,7 @@ use Geocoder\Query\ReverseQuery; use Geocoder\Provider\Pelias\Pelias; use Geocoder\Provider\Provider; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; final class GeocodeEarth extends Pelias implements Provider { @@ -32,10 +32,10 @@ final class GeocodeEarth extends Pelias implements Provider private $apiKey; /** - * @param HttpClient $client an HTTP adapter - * @param string $apiKey an API key + * @param ClientInterface $client an HTTP adapter + * @param string $apiKey an API key */ - public function __construct(HttpClient $client, string $apiKey) + public function __construct(ClientInterface $client, string $apiKey) { if (empty($apiKey)) { throw new InvalidCredentials('No API key provided.'); diff --git a/src/Provider/GeocodeEarth/Tests/IntegrationTest.php b/src/Provider/GeocodeEarth/Tests/IntegrationTest.php index 52b6745c7..ee203c608 100644 --- a/src/Provider/GeocodeEarth/Tests/IntegrationTest.php +++ b/src/Provider/GeocodeEarth/Tests/IntegrationTest.php @@ -14,7 +14,7 @@ use Geocoder\IntegrationTest\ProviderIntegrationTest; use Geocoder\Provider\GeocodeEarth\GeocodeEarth; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author Tobias Nyholm @@ -29,7 +29,7 @@ class IntegrationTest extends ProviderIntegrationTest protected $testIpv6 = false; - protected function createProvider(HttpClient $httpClient) + protected function createProvider(ClientInterface $httpClient) { return new GeocodeEarth($httpClient, $this->getApiKey()); } diff --git a/src/Provider/Geoip/Tests/IntegrationTest.php b/src/Provider/Geoip/Tests/IntegrationTest.php index bdde2ffb8..fa5fc111c 100644 --- a/src/Provider/Geoip/Tests/IntegrationTest.php +++ b/src/Provider/Geoip/Tests/IntegrationTest.php @@ -14,7 +14,7 @@ use Geocoder\IntegrationTest\ProviderIntegrationTest; use Geocoder\Provider\Geoip\Geoip; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author Tobias Nyholm @@ -36,7 +36,7 @@ protected function setUp(): void } } - protected function createProvider(HttpClient $httpClient) + protected function createProvider(ClientInterface $httpClient) { return new Geoip(); } diff --git a/src/Provider/Geonames/Geonames.php b/src/Provider/Geonames/Geonames.php index 9c88cae8a..8ef2539f1 100644 --- a/src/Provider/Geonames/Geonames.php +++ b/src/Provider/Geonames/Geonames.php @@ -25,7 +25,7 @@ use Geocoder\Query\ReverseQuery; use Geocoder\Http\Provider\AbstractHttpProvider; use Geocoder\Provider\Provider; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author Giovanni Pirrotta @@ -53,10 +53,10 @@ final class Geonames extends AbstractHttpProvider implements Provider private $username; /** - * @param HttpClient $client An HTTP adapter - * @param string $username Username login (Free registration at http://www.geonames.org/login) + * @param ClientInterface $client An HTTP adapter + * @param string $username Username login (Free registration at http://www.geonames.org/login) */ - public function __construct(HttpClient $client, string $username) + public function __construct(ClientInterface $client, string $username) { if (empty($username)) { throw new InvalidCredentials('No username provided.'); diff --git a/src/Provider/Geonames/Tests/IntegrationTest.php b/src/Provider/Geonames/Tests/IntegrationTest.php index 13a13da1d..7a162dafd 100644 --- a/src/Provider/Geonames/Tests/IntegrationTest.php +++ b/src/Provider/Geonames/Tests/IntegrationTest.php @@ -12,7 +12,7 @@ use Geocoder\IntegrationTest\ProviderIntegrationTest; use Geocoder\Provider\Geonames\Geonames; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author Tobias Nyholm @@ -27,7 +27,7 @@ class IntegrationTest extends ProviderIntegrationTest protected $testIpv6 = false; - protected function createProvider(HttpClient $httpClient) + protected function createProvider(ClientInterface $httpClient) { return new Geonames($httpClient, $this->getApiKey()); } diff --git a/src/Provider/GoogleMaps/GoogleMaps.php b/src/Provider/GoogleMaps/GoogleMaps.php index f2d27196c..e40a6c91a 100644 --- a/src/Provider/GoogleMaps/GoogleMaps.php +++ b/src/Provider/GoogleMaps/GoogleMaps.php @@ -24,7 +24,7 @@ use Geocoder\Provider\Provider; use Geocoder\Query\GeocodeQuery; use Geocoder\Query\ReverseQuery; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author William Durand @@ -71,17 +71,17 @@ final class GoogleMaps extends AbstractHttpProvider implements Provider * https://developers.google.com/maps/documentation/business/ * Maps for Business is no longer accepting new signups. * - * @param HttpClient $client An HTTP adapter - * @param string $clientId Your Client ID - * @param string $privateKey Your Private Key (optional) - * @param string $region Region biasing (optional) - * @param string $apiKey Google Geocoding API key (optional) - * @param string $channel Google Channel parameter (optional) + * @param ClientInterface $client An HTTP adapter + * @param string $clientId Your Client ID + * @param string $privateKey Your Private Key (optional) + * @param string $region Region biasing (optional) + * @param string $apiKey Google Geocoding API key (optional) + * @param string $channel Google Channel parameter (optional) * * @return GoogleMaps */ public static function business( - HttpClient $client, + ClientInterface $client, string $clientId, string $privateKey = null, string $region = null, @@ -97,11 +97,11 @@ public static function business( } /** - * @param HttpClient $client An HTTP adapter - * @param string $region Region biasing (optional) - * @param string $apiKey Google Geocoding API key (optional) + * @param ClientInterface $client An HTTP adapter + * @param string $region Region biasing (optional) + * @param string $apiKey Google Geocoding API key (optional) */ - public function __construct(HttpClient $client, string $region = null, string $apiKey = null) + public function __construct(ClientInterface $client, string $region = null, string $apiKey = null) { parent::__construct($client); diff --git a/src/Provider/GoogleMaps/Readme.md b/src/Provider/GoogleMaps/Readme.md index 64e277353..8702e9871 100644 --- a/src/Provider/GoogleMaps/Readme.md +++ b/src/Provider/GoogleMaps/Readme.md @@ -8,12 +8,12 @@ [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE) This is the Google Maps provider from the PHP Geocoder. This is a **READ ONLY** repository. See the -[main repo](https://github.com/geocoder-php/Geocoder) for information and documentation. +[main repo](https://github.com/geocoder-php/Geocoder) for information and documentation. ## Usage ```php -$httpClient = new \Http\Adapter\Guzzle6\Client(); +$httpClient = new \GuzzleHttp\Client(); // You must provide an API key $provider = new \Geocoder\Provider\GoogleMaps\GoogleMaps($httpClient, null, 'your-api-key'); @@ -31,7 +31,7 @@ can use the static `business` method on the provider to create a client: ```php -$httpClient = new \Http\Adapter\Guzzle6\Client(); +$httpClient = new \GuzzleHttp\Client(); // Client ID is required. Private key is optional. $provider = \Geocoder\Provider\GoogleMaps\GoogleMaps::business($httpClient, 'your-client-id', 'your-private-key'); @@ -49,5 +49,5 @@ composer require geocoder-php/google-maps-provider ### Contribute -Contributions are very welcome! Send a pull request to the [main repository](https://github.com/geocoder-php/Geocoder) or +Contributions are very welcome! Send a pull request to the [main repository](https://github.com/geocoder-php/Geocoder) or report any issues you find on the [issue tracker](https://github.com/geocoder-php/Geocoder/issues). diff --git a/src/Provider/GoogleMaps/Tests/IntegrationTest.php b/src/Provider/GoogleMaps/Tests/IntegrationTest.php index 22f1f8fab..080949ef3 100644 --- a/src/Provider/GoogleMaps/Tests/IntegrationTest.php +++ b/src/Provider/GoogleMaps/Tests/IntegrationTest.php @@ -14,7 +14,7 @@ use Geocoder\IntegrationTest\ProviderIntegrationTest; use Geocoder\Provider\GoogleMaps\GoogleMaps; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author Tobias Nyholm @@ -25,7 +25,7 @@ class IntegrationTest extends ProviderIntegrationTest protected $testIpv6 = false; - protected function createProvider(HttpClient $httpClient) + protected function createProvider(ClientInterface $httpClient) { return new GoogleMaps($httpClient, null, $_SERVER['GOOGLE_GEOCODING_KEY']); } diff --git a/src/Provider/GoogleMapsPlaces/GoogleMapsPlaces.php b/src/Provider/GoogleMapsPlaces/GoogleMapsPlaces.php index 5212aeed0..079afa2fc 100644 --- a/src/Provider/GoogleMapsPlaces/GoogleMapsPlaces.php +++ b/src/Provider/GoogleMapsPlaces/GoogleMapsPlaces.php @@ -29,7 +29,7 @@ use Geocoder\Query\GeocodeQuery; use Geocoder\Query\Query; use Geocoder\Query\ReverseQuery; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; use stdClass; /** @@ -83,10 +83,10 @@ final class GoogleMapsPlaces extends AbstractHttpProvider implements Provider private $apiKey; /** - * @param HttpClient $client An HTTP adapter - * @param string $apiKey Google Maps Places API Key + * @param ClientInterface $client An HTTP adapter + * @param string $apiKey Google Maps Places API Key */ - public function __construct(HttpClient $client, string $apiKey) + public function __construct(ClientInterface $client, string $apiKey) { parent::__construct($client); diff --git a/src/Provider/GoogleMapsPlaces/Tests/IntegrationTest.php b/src/Provider/GoogleMapsPlaces/Tests/IntegrationTest.php index 509f437ba..bc9af9eb7 100644 --- a/src/Provider/GoogleMapsPlaces/Tests/IntegrationTest.php +++ b/src/Provider/GoogleMapsPlaces/Tests/IntegrationTest.php @@ -14,7 +14,7 @@ use Geocoder\IntegrationTest\ProviderIntegrationTest; use Geocoder\Provider\GoogleMapsPlaces\GoogleMapsPlaces; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author Tobias Nyholm @@ -29,7 +29,7 @@ class IntegrationTest extends ProviderIntegrationTest protected $testIpv6 = false; - protected function createProvider(HttpClient $httpClient) + protected function createProvider(ClientInterface $httpClient) { return new GoogleMapsPlaces($httpClient, $_SERVER['GOOGLE_GEOCODING_KEY']); } diff --git a/src/Provider/GraphHopper/GraphHopper.php b/src/Provider/GraphHopper/GraphHopper.php index 7796685af..28793dfd2 100644 --- a/src/Provider/GraphHopper/GraphHopper.php +++ b/src/Provider/GraphHopper/GraphHopper.php @@ -22,7 +22,7 @@ use Geocoder\Query\ReverseQuery; use Geocoder\Http\Provider\AbstractHttpProvider; use Geocoder\Provider\Provider; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author Gary Gale @@ -45,10 +45,10 @@ final class GraphHopper extends AbstractHttpProvider implements Provider private $apiKey; /** - * @param HttpClient $client an HTTP adapter - * @param string $apiKey an API key + * @param ClientInterface $client an HTTP adapter + * @param string $apiKey an API key */ - public function __construct(HttpClient $client, string $apiKey) + public function __construct(ClientInterface $client, string $apiKey) { if (empty($apiKey)) { throw new InvalidCredentials('No API key provided.'); diff --git a/src/Provider/GraphHopper/Tests/IntegrationTest.php b/src/Provider/GraphHopper/Tests/IntegrationTest.php index 45443f8ac..6abb2cc70 100644 --- a/src/Provider/GraphHopper/Tests/IntegrationTest.php +++ b/src/Provider/GraphHopper/Tests/IntegrationTest.php @@ -14,7 +14,7 @@ use Geocoder\IntegrationTest\ProviderIntegrationTest; use Geocoder\Provider\GraphHopper\GraphHopper; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author Tobias Nyholm @@ -30,7 +30,7 @@ class IntegrationTest extends ProviderIntegrationTest protected $testIpv6 = false; - protected function createProvider(HttpClient $httpClient) + protected function createProvider(ClientInterface $httpClient) { return new GraphHopper($httpClient, $this->getApiKey()); } diff --git a/src/Provider/Here/Here.php b/src/Provider/Here/Here.php index 6b82c5f91..a5a260f3b 100644 --- a/src/Provider/Here/Here.php +++ b/src/Provider/Here/Here.php @@ -25,7 +25,7 @@ use Geocoder\Query\Query; use Geocoder\Query\GeocodeQuery; use Geocoder\Query\ReverseQuery; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author Sébastien Barré @@ -116,12 +116,12 @@ final class Here extends AbstractHttpProvider implements Provider private $apiKey; /** - * @param HttpClient $client an HTTP adapter - * @param string $appId an App ID - * @param string $appCode an App code - * @param bool $useCIT use Customer Integration Testing environment (CIT) instead of production + * @param ClientInterface $client an HTTP adapter + * @param string $appId an App ID + * @param string $appCode an App code + * @param bool $useCIT use Customer Integration Testing environment (CIT) instead of production */ - public function __construct(HttpClient $client, string $appId = null, string $appCode = null, bool $useCIT = false) + public function __construct(ClientInterface $client, string $appId = null, string $appCode = null, bool $useCIT = false) { $this->appId = $appId; $this->appCode = $appCode; @@ -130,7 +130,7 @@ public function __construct(HttpClient $client, string $appId = null, string $ap parent::__construct($client); } - public static function createUsingApiKey(HttpClient $client, string $apiKey, bool $useCIT = false): self + public static function createUsingApiKey(ClientInterface $client, string $apiKey, bool $useCIT = false): self { $client = new self($client, null, null, $useCIT); $client->apiKey = $apiKey; diff --git a/src/Provider/Here/Readme.md b/src/Provider/Here/Readme.md index 0b5ebca68..1a4113cec 100644 --- a/src/Provider/Here/Readme.md +++ b/src/Provider/Here/Readme.md @@ -24,7 +24,7 @@ composer require geocoder-php/here-provider New applications on the Here platform use the `api_key` authentication method. ```php -$httpClient = new \Http\Adapter\Guzzle6\Client(); +$httpClient = new \GuzzleHttp\Client(); // You must provide an API key $provider = \Geocoder\Provider\Here\Here::createUsingApiKey($httpClient, 'your-api-key'); @@ -35,7 +35,7 @@ $result = $geocoder->geocodeQuery(GeocodeQuery::create('Buckingham Palace, Londo If you're using the legacy `app_code` authentication method, use the constructor on the provider like so: ```php -$httpClient = new \Http\Adapter\Guzzle6\Client(); +$httpClient = new \GuzzleHttp\Client(); // You must provide both the app_id and app_code $provider = new \Geocoder\Provider\Here\Here($httpClient, 'app-id', 'app-code'); diff --git a/src/Provider/Here/Tests/IntegrationTest.php b/src/Provider/Here/Tests/IntegrationTest.php index 3ea04510c..5ba496905 100644 --- a/src/Provider/Here/Tests/IntegrationTest.php +++ b/src/Provider/Here/Tests/IntegrationTest.php @@ -21,8 +21,8 @@ use Geocoder\Model\Country; use Geocoder\Query\GeocodeQuery; use Geocoder\Query\ReverseQuery; -use Http\Client\HttpClient; -use Http\Discovery\HttpClientDiscovery; +use Http\Discovery\Psr18ClientDiscovery; +use Psr\Http\Client\ClientInterface; /** * @author Sébastien Barré @@ -33,7 +33,7 @@ class IntegrationTest extends ProviderIntegrationTest protected $testIpv6 = false; - protected function createProvider(HttpClient $httpClient, bool $useCIT = false) + protected function createProvider(ClientInterface $httpClient, bool $useCIT = false) { return Here::createUsingApiKey($httpClient, $this->getApiKey(), $useCIT); } @@ -51,9 +51,9 @@ protected function getCacheDir() private function getCachedHttpClient() { try { - $client = HttpClientDiscovery::find(); - } catch (\Http\Discovery\NotFoundException $e) { - $client = $this->getMockForAbstractClass(HttpClient::class); + $client = Psr18ClientDiscovery::find(); + } catch (\Http\Discovery\Exception\NotFoundException $e) { + $client = $this->getMockForAbstractClass(ClientInterface::class); $client ->expects($this->any()) diff --git a/src/Provider/HostIp/Tests/IntegrationTest.php b/src/Provider/HostIp/Tests/IntegrationTest.php index cda26c318..530ca08f0 100644 --- a/src/Provider/HostIp/Tests/IntegrationTest.php +++ b/src/Provider/HostIp/Tests/IntegrationTest.php @@ -14,7 +14,7 @@ use Geocoder\IntegrationTest\ProviderIntegrationTest; use Geocoder\Provider\HostIp\HostIp; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author Tobias Nyholm @@ -31,7 +31,7 @@ class IntegrationTest extends ProviderIntegrationTest protected $testIpv6 = false; - protected function createProvider(HttpClient $httpClient) + protected function createProvider(ClientInterface $httpClient) { return new HostIp($httpClient); } diff --git a/src/Provider/IP2Location/IP2Location.php b/src/Provider/IP2Location/IP2Location.php index 58f60c74c..d082a29f1 100644 --- a/src/Provider/IP2Location/IP2Location.php +++ b/src/Provider/IP2Location/IP2Location.php @@ -21,7 +21,7 @@ use Geocoder\Query\ReverseQuery; use Geocoder\Http\Provider\AbstractHttpProvider; use Geocoder\Provider\Provider; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author William Durand @@ -44,10 +44,10 @@ final class IP2Location extends AbstractHttpProvider implements Provider private $endpointUrl; /** - * @param HttpClient $client a HTTP adapter - * @param string $apiKey an API key + * @param ClientInterface $client a HTTP adapter + * @param string $apiKey an API key */ - public function __construct(HttpClient $client, string $apiKey) + public function __construct(ClientInterface $client, string $apiKey) { parent::__construct($client); diff --git a/src/Provider/IP2Location/Tests/IntegrationTest.php b/src/Provider/IP2Location/Tests/IntegrationTest.php index 825c78f6f..d06774043 100644 --- a/src/Provider/IP2Location/Tests/IntegrationTest.php +++ b/src/Provider/IP2Location/Tests/IntegrationTest.php @@ -12,7 +12,7 @@ use Geocoder\IntegrationTest\ProviderIntegrationTest; use Geocoder\Provider\IP2Location\IP2Location; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author IP2Location @@ -23,7 +23,7 @@ class IntegrationTest extends ProviderIntegrationTest protected $testReverse = false; - protected function createProvider(HttpClient $httpClient) + protected function createProvider(ClientInterface $httpClient) { return new IP2Location($httpClient, $this->getApiKey()); } diff --git a/src/Provider/IP2LocationBinary/Tests/IntegrationTest.php b/src/Provider/IP2LocationBinary/Tests/IntegrationTest.php index bc00d8e7b..ec64b0a4a 100644 --- a/src/Provider/IP2LocationBinary/Tests/IntegrationTest.php +++ b/src/Provider/IP2LocationBinary/Tests/IntegrationTest.php @@ -14,7 +14,7 @@ use Geocoder\IntegrationTest\ProviderIntegrationTest; use Geocoder\Provider\IP2LocationBinary\IP2LocationBinary; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author IP2Location @@ -41,7 +41,7 @@ public static function setUpBeforeClass(): void parent::setUpBeforeClass(); } - protected function createProvider(HttpClient $httpClient) + protected function createProvider(ClientInterface $httpClient) { // Download this BIN database from https://lite.ip2location.com/database/ip-country-region-city-latitude-longitude-zipcode return new IP2LocationBinary(__DIR__.'/fixtures/IP2LOCATION-LITE-DB9.IPV6.BIN', \IP2Location\Database::FILE_IO); diff --git a/src/Provider/IpInfo/Tests/IntegrationTest.php b/src/Provider/IpInfo/Tests/IntegrationTest.php index 172da0401..fc7a1d064 100644 --- a/src/Provider/IpInfo/Tests/IntegrationTest.php +++ b/src/Provider/IpInfo/Tests/IntegrationTest.php @@ -14,7 +14,7 @@ use Geocoder\IntegrationTest\ProviderIntegrationTest; use Geocoder\Provider\IpInfo\IpInfo; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author Tobias Nyholm @@ -27,7 +27,7 @@ class IntegrationTest extends ProviderIntegrationTest protected $testIpv6 = true; - protected function createProvider(HttpClient $httpClient) + protected function createProvider(ClientInterface $httpClient) { return new IpInfo($httpClient); } diff --git a/src/Provider/IpInfoDb/IpInfoDb.php b/src/Provider/IpInfoDb/IpInfoDb.php index 2b7a2d37c..6fed72b0c 100644 --- a/src/Provider/IpInfoDb/IpInfoDb.php +++ b/src/Provider/IpInfoDb/IpInfoDb.php @@ -22,7 +22,7 @@ use Geocoder\Query\ReverseQuery; use Geocoder\Http\Provider\AbstractHttpProvider; use Geocoder\Provider\Provider; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author William Durand @@ -50,13 +50,13 @@ final class IpInfoDb extends AbstractHttpProvider implements Provider private $endpointUrl; /** - * @param HttpClient $client an HTTP adapter - * @param string $apiKey an API key - * @param string $precision The endpoint precision. Either "city" or "country" (faster) + * @param ClientInterface $client an HTTP adapter + * @param string $apiKey an API key + * @param string $precision The endpoint precision. Either "city" or "country" (faster) * * @throws \Geocoder\Exception\InvalidArgument */ - public function __construct(HttpClient $client, string $apiKey, string $precision = 'city') + public function __construct(ClientInterface $client, string $apiKey, string $precision = 'city') { parent::__construct($client); diff --git a/src/Provider/IpInfoDb/Tests/IntegrationTest.php b/src/Provider/IpInfoDb/Tests/IntegrationTest.php index bc3ac4720..d6677384d 100644 --- a/src/Provider/IpInfoDb/Tests/IntegrationTest.php +++ b/src/Provider/IpInfoDb/Tests/IntegrationTest.php @@ -14,7 +14,7 @@ use Geocoder\IntegrationTest\ProviderIntegrationTest; use Geocoder\Provider\IpInfoDb\IpInfoDb; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author Tobias Nyholm @@ -27,7 +27,7 @@ class IntegrationTest extends ProviderIntegrationTest protected $testIpv6 = false; - protected function createProvider(HttpClient $httpClient) + protected function createProvider(ClientInterface $httpClient) { return new IpInfoDb($httpClient, $this->getApiKey()); } diff --git a/src/Provider/Ipstack/Ipstack.php b/src/Provider/Ipstack/Ipstack.php index 160af8e6e..921e30314 100644 --- a/src/Provider/Ipstack/Ipstack.php +++ b/src/Provider/Ipstack/Ipstack.php @@ -23,7 +23,7 @@ use Geocoder\Query\ReverseQuery; use Geocoder\Http\Provider\AbstractHttpProvider; use Geocoder\Provider\Provider; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author Jonas Gielen @@ -41,10 +41,10 @@ final class Ipstack extends AbstractHttpProvider implements Provider private $apiKey; /** - * @param HttpClient $client an HTTP adapter - * @param string $apiKey an API key + * @param ClientInterface $client an HTTP adapter + * @param string $apiKey an API key */ - public function __construct(HttpClient $client, string $apiKey) + public function __construct(ClientInterface $client, string $apiKey) { if (empty($apiKey)) { throw new InvalidCredentials('No API key provided.'); diff --git a/src/Provider/Ipstack/Tests/IntegrationTest.php b/src/Provider/Ipstack/Tests/IntegrationTest.php index c81a003e4..f8d40ec3c 100644 --- a/src/Provider/Ipstack/Tests/IntegrationTest.php +++ b/src/Provider/Ipstack/Tests/IntegrationTest.php @@ -14,7 +14,7 @@ use Geocoder\IntegrationTest\ProviderIntegrationTest; use Geocoder\Provider\Ipstack\Ipstack; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author Jonas Gielen @@ -25,7 +25,7 @@ class IntegrationTest extends ProviderIntegrationTest protected $testReverse = false; - protected function createProvider(HttpClient $httpClient) + protected function createProvider(ClientInterface $httpClient) { return new Ipstack($httpClient, $this->getApiKey()); } diff --git a/src/Provider/LocationIQ/LocationIQ.php b/src/Provider/LocationIQ/LocationIQ.php index 93ab3797a..24f6ded67 100644 --- a/src/Provider/LocationIQ/LocationIQ.php +++ b/src/Provider/LocationIQ/LocationIQ.php @@ -23,7 +23,7 @@ use Geocoder\Query\ReverseQuery; use Geocoder\Http\Provider\AbstractHttpProvider; use Geocoder\Provider\Provider; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author Srihari Thalla @@ -54,10 +54,10 @@ final class LocationIQ extends AbstractHttpProvider implements Provider private $apiKey; /** - * @param HttpClient $client an HTTP adapter - * @param string $apiKey an API key + * @param ClientInterface $client an HTTP adapter + * @param string $apiKey an API key */ - public function __construct(HttpClient $client, string $apiKey, string $region = null) + public function __construct(ClientInterface $client, string $apiKey, string $region = null) { if (empty($apiKey)) { throw new InvalidCredentials('No API key provided.'); diff --git a/src/Provider/LocationIQ/Tests/IntegrationTest.php b/src/Provider/LocationIQ/Tests/IntegrationTest.php index 528d079d5..fe45fc20b 100644 --- a/src/Provider/LocationIQ/Tests/IntegrationTest.php +++ b/src/Provider/LocationIQ/Tests/IntegrationTest.php @@ -12,7 +12,7 @@ use Geocoder\IntegrationTest\ProviderIntegrationTest; use Geocoder\Provider\LocationIQ\LocationIQ; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author Srihari Thalla @@ -27,7 +27,7 @@ class IntegrationTest extends ProviderIntegrationTest protected $testIpv6 = false; - protected function createProvider(HttpClient $httpClient) + protected function createProvider(ClientInterface $httpClient) { return new LocationIQ($httpClient, $this->getApiKey()); } diff --git a/src/Provider/MapQuest/MapQuest.php b/src/Provider/MapQuest/MapQuest.php index c912cf517..325f8f983 100644 --- a/src/Provider/MapQuest/MapQuest.php +++ b/src/Provider/MapQuest/MapQuest.php @@ -28,7 +28,7 @@ use Geocoder\Query\GeocodeQuery; use Geocoder\Query\ReverseQuery; use Geocoder\Provider\Provider; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; use Psr\Http\Message\ResponseInterface; /** @@ -100,12 +100,12 @@ final class MapQuest extends AbstractHttpProvider implements Provider private $apiKey; /** - * @param HttpClient $client an HTTP adapter - * @param string $apiKey an API key - * @param bool $licensed true to use MapQuest's licensed endpoints, default is false to use the open endpoints (optional) - * @param bool $useRoadPosition true to use nearest point on a road for the entrance, false to use map display position + * @param ClientInterface $client an HTTP adapter + * @param string $apiKey an API key + * @param bool $licensed true to use MapQuest's licensed endpoints, default is false to use the open endpoints (optional) + * @param bool $useRoadPosition true to use nearest point on a road for the entrance, false to use map display position */ - public function __construct(HttpClient $client, string $apiKey, bool $licensed = false, bool $useRoadPosition = false) + public function __construct(ClientInterface $client, string $apiKey, bool $licensed = false, bool $useRoadPosition = false) { if (empty($apiKey)) { throw new InvalidCredentials('No API key provided.'); diff --git a/src/Provider/MapQuest/Tests/IntegrationTest.php b/src/Provider/MapQuest/Tests/IntegrationTest.php index b81ca7c48..cb36b3a06 100644 --- a/src/Provider/MapQuest/Tests/IntegrationTest.php +++ b/src/Provider/MapQuest/Tests/IntegrationTest.php @@ -14,7 +14,7 @@ use Geocoder\IntegrationTest\ProviderIntegrationTest; use Geocoder\Provider\MapQuest\MapQuest; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author Tobias Nyholm @@ -25,7 +25,7 @@ class IntegrationTest extends ProviderIntegrationTest protected $testIpv6 = false; - protected function createProvider(HttpClient $httpClient) + protected function createProvider(ClientInterface $httpClient) { return new MapQuest($httpClient, $this->getApiKey()); } diff --git a/src/Provider/Mapbox/Mapbox.php b/src/Provider/Mapbox/Mapbox.php index 3c25b613f..a99ecdae7 100644 --- a/src/Provider/Mapbox/Mapbox.php +++ b/src/Provider/Mapbox/Mapbox.php @@ -23,7 +23,7 @@ use Geocoder\Http\Provider\AbstractHttpProvider; use Geocoder\Provider\Mapbox\Model\MapboxAddress; use Geocoder\Provider\Provider; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; final class Mapbox extends AbstractHttpProvider implements Provider { @@ -124,7 +124,7 @@ final class Mapbox extends AbstractHttpProvider implements Provider const DEFAULT_TYPE = self::TYPE_ADDRESS; /** - * @var HttpClient + * @var ClientInterface */ private $client; @@ -144,13 +144,13 @@ final class Mapbox extends AbstractHttpProvider implements Provider private $geocodingMode; /** - * @param HttpClient $client An HTTP adapter - * @param string $accessToken Your Mapbox access token - * @param string|null $country - * @param string $geocodingMode + * @param ClientInterface $client An HTTP adapter + * @param string $accessToken Your Mapbox access token + * @param string|null $country + * @param string $geocodingMode */ public function __construct( - HttpClient $client, + ClientInterface $client, string $accessToken, string $country = null, string $geocodingMode = self::GEOCODING_MODE_PLACES diff --git a/src/Provider/Mapbox/Tests/IntegrationTest.php b/src/Provider/Mapbox/Tests/IntegrationTest.php index 2bc69c245..c1b9e46ab 100644 --- a/src/Provider/Mapbox/Tests/IntegrationTest.php +++ b/src/Provider/Mapbox/Tests/IntegrationTest.php @@ -14,7 +14,7 @@ use Geocoder\IntegrationTest\ProviderIntegrationTest; use Geocoder\Provider\Mapbox\Mapbox; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author Tobias Nyholm @@ -25,7 +25,7 @@ class IntegrationTest extends ProviderIntegrationTest protected $testIpv6 = false; - protected function createProvider(HttpClient $httpClient) + protected function createProvider(ClientInterface $httpClient) { return new Mapbox($httpClient, $this->getApiKey()); } diff --git a/src/Provider/Mapzen/Mapzen.php b/src/Provider/Mapzen/Mapzen.php index 66b9ec997..fbeea8f15 100644 --- a/src/Provider/Mapzen/Mapzen.php +++ b/src/Provider/Mapzen/Mapzen.php @@ -22,7 +22,7 @@ use Geocoder\Query\ReverseQuery; use Geocoder\Http\Provider\AbstractHttpProvider; use Geocoder\Provider\Provider; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * Mapzen has shut down as their APIs as of February 1, 2018. @@ -51,10 +51,10 @@ final class Mapzen extends AbstractHttpProvider implements Provider * * @deprecated https://github.com/geocoder-php/Geocoder/issues/808 * - * @param HttpClient $client an HTTP adapter - * @param string $apiKey an API key + * @param ClientInterface $client an HTTP adapter + * @param string $apiKey an API key */ - public function __construct(HttpClient $client, string $apiKey) + public function __construct(ClientInterface $client, string $apiKey) { if (empty($apiKey)) { throw new InvalidCredentials('No API key provided.'); diff --git a/src/Provider/Mapzen/Tests/IntegrationTest.php b/src/Provider/Mapzen/Tests/IntegrationTest.php index 8386e0e93..4bee9e49f 100644 --- a/src/Provider/Mapzen/Tests/IntegrationTest.php +++ b/src/Provider/Mapzen/Tests/IntegrationTest.php @@ -14,7 +14,7 @@ use Geocoder\IntegrationTest\ProviderIntegrationTest; use Geocoder\Provider\Mapzen\Mapzen; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author Tobias Nyholm @@ -30,7 +30,7 @@ class IntegrationTest extends ProviderIntegrationTest protected $testIpv6 = false; - protected function createProvider(HttpClient $httpClient) + protected function createProvider(ClientInterface $httpClient) { return new Mapzen($httpClient, $this->getApiKey()); } diff --git a/src/Provider/MaxMind/MaxMind.php b/src/Provider/MaxMind/MaxMind.php index e9aea4ddb..379fcd68a 100644 --- a/src/Provider/MaxMind/MaxMind.php +++ b/src/Provider/MaxMind/MaxMind.php @@ -22,7 +22,7 @@ use Geocoder\Query\ReverseQuery; use Geocoder\Http\Provider\AbstractHttpProvider; use Geocoder\Provider\Provider; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author Andrea Cristaudo @@ -55,11 +55,11 @@ final class MaxMind extends AbstractHttpProvider implements Provider private $service = null; /** - * @param HttpClient $client an HTTP adapter - * @param string $apiKey an API key - * @param string $service the specific Maxmind service to use (optional) + * @param ClientInterface $client an HTTP adapter + * @param string $apiKey an API key + * @param string $service the specific Maxmind service to use (optional) */ - public function __construct(HttpClient $client, string $apiKey, string $service = self::CITY_EXTENDED_SERVICE) + public function __construct(ClientInterface $client, string $apiKey, string $service = self::CITY_EXTENDED_SERVICE) { if (empty($apiKey)) { throw new InvalidCredentials('No API key provided.'); diff --git a/src/Provider/MaxMind/Tests/IntegrationTest.php b/src/Provider/MaxMind/Tests/IntegrationTest.php index 0e9a7b5c1..e14e7daf0 100644 --- a/src/Provider/MaxMind/Tests/IntegrationTest.php +++ b/src/Provider/MaxMind/Tests/IntegrationTest.php @@ -12,7 +12,7 @@ use Geocoder\IntegrationTest\ProviderIntegrationTest; use Geocoder\Provider\MaxMind\MaxMind; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author Tobias Nyholm @@ -23,7 +23,7 @@ class IntegrationTest extends ProviderIntegrationTest protected $testReverse = false; - protected function createProvider(HttpClient $httpClient) + protected function createProvider(ClientInterface $httpClient) { return new MaxMind($httpClient, $this->getApiKey()); } diff --git a/src/Provider/MaxMindBinary/Tests/IntegrationTest.php b/src/Provider/MaxMindBinary/Tests/IntegrationTest.php index 38d185b8d..c13986e49 100644 --- a/src/Provider/MaxMindBinary/Tests/IntegrationTest.php +++ b/src/Provider/MaxMindBinary/Tests/IntegrationTest.php @@ -14,7 +14,7 @@ use Geocoder\IntegrationTest\ProviderIntegrationTest; use Geocoder\Provider\MaxMindBinary\MaxMindBinary; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author Tobias Nyholm @@ -45,7 +45,7 @@ public static function setUpBeforeClass(): void parent::setUpBeforeClass(); } - protected function createProvider(HttpClient $httpClient) + protected function createProvider(ClientInterface $httpClient) { return new MaxMindBinary(__DIR__.'/fixtures/GeoLiteCity.dat'); } diff --git a/src/Provider/Nominatim/Nominatim.php b/src/Provider/Nominatim/Nominatim.php index aeb6d97ad..00df9b40c 100644 --- a/src/Provider/Nominatim/Nominatim.php +++ b/src/Provider/Nominatim/Nominatim.php @@ -24,7 +24,7 @@ use Geocoder\Http\Provider\AbstractHttpProvider; use Geocoder\Provider\Provider; use Geocoder\Provider\Nominatim\Model\NominatimAddress; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author Niklas Närhinen @@ -48,24 +48,24 @@ final class Nominatim extends AbstractHttpProvider implements Provider private $referer; /** - * @param HttpClient $client an HTTP client - * @param string $userAgent Value of the User-Agent header - * @param string $referer Value of the Referer header + * @param ClientInterface $client an HTTP client + * @param string $userAgent Value of the User-Agent header + * @param string $referer Value of the Referer header * * @return Nominatim */ - public static function withOpenStreetMapServer(HttpClient $client, string $userAgent, string $referer = ''): self + public static function withOpenStreetMapServer(ClientInterface $client, string $userAgent, string $referer = ''): self { return new self($client, 'https://nominatim.openstreetmap.org', $userAgent, $referer); } /** - * @param HttpClient $client an HTTP client - * @param string $rootUrl Root URL of the nominatim server - * @param string $userAgent Value of the User-Agent header - * @param string $referer Value of the Referer header + * @param ClientInterface $client an HTTP client + * @param string $rootUrl Root URL of the nominatim server + * @param string $userAgent Value of the User-Agent header + * @param string $referer Value of the Referer header */ - public function __construct(HttpClient $client, $rootUrl, string $userAgent, string $referer = '') + public function __construct(ClientInterface $client, $rootUrl, string $userAgent, string $referer = '') { parent::__construct($client); diff --git a/src/Provider/Nominatim/Tests/IntegrationTest.php b/src/Provider/Nominatim/Tests/IntegrationTest.php index 66ef34e0f..7ee37b8e7 100644 --- a/src/Provider/Nominatim/Tests/IntegrationTest.php +++ b/src/Provider/Nominatim/Tests/IntegrationTest.php @@ -12,7 +12,7 @@ use Geocoder\IntegrationTest\ProviderIntegrationTest; use Geocoder\Provider\Nominatim\Nominatim; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author Tobias Nyholm @@ -31,7 +31,7 @@ class IntegrationTest extends ProviderIntegrationTest protected $testIpv6 = false; - protected function createProvider(HttpClient $httpClient) + protected function createProvider(ClientInterface $httpClient) { return Nominatim::withOpenStreetMapServer($httpClient, 'Geocoder PHP/Nominatim Provider/Integration Test'); } diff --git a/src/Provider/OpenCage/OpenCage.php b/src/Provider/OpenCage/OpenCage.php index a6ee13613..6688b67b0 100644 --- a/src/Provider/OpenCage/OpenCage.php +++ b/src/Provider/OpenCage/OpenCage.php @@ -24,7 +24,7 @@ use Geocoder\Query\ReverseQuery; use Geocoder\Http\Provider\AbstractHttpProvider; use Geocoder\Provider\Provider; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author mtm @@ -42,10 +42,10 @@ final class OpenCage extends AbstractHttpProvider implements Provider private $apiKey; /** - * @param HttpClient $client an HTTP adapter - * @param string $apiKey an API key + * @param ClientInterface $client an HTTP adapter + * @param string $apiKey an API key */ - public function __construct(HttpClient $client, string $apiKey) + public function __construct(ClientInterface $client, string $apiKey) { if (empty($apiKey)) { throw new InvalidCredentials('No API key provided.'); diff --git a/src/Provider/OpenCage/Tests/IntegrationTest.php b/src/Provider/OpenCage/Tests/IntegrationTest.php index 422152686..895ea6d78 100644 --- a/src/Provider/OpenCage/Tests/IntegrationTest.php +++ b/src/Provider/OpenCage/Tests/IntegrationTest.php @@ -14,7 +14,7 @@ use Geocoder\IntegrationTest\ProviderIntegrationTest; use Geocoder\Provider\OpenCage\OpenCage; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author Tobias Nyholm @@ -29,7 +29,7 @@ class IntegrationTest extends ProviderIntegrationTest protected $testIpv6 = false; - protected function createProvider(HttpClient $httpClient) + protected function createProvider(ClientInterface $httpClient) { return new OpenCage($httpClient, $this->getApiKey()); } diff --git a/src/Provider/OpenRouteService/OpenRouteService.php b/src/Provider/OpenRouteService/OpenRouteService.php index 640447e30..38239e793 100644 --- a/src/Provider/OpenRouteService/OpenRouteService.php +++ b/src/Provider/OpenRouteService/OpenRouteService.php @@ -18,7 +18,7 @@ use Geocoder\Query\ReverseQuery; use Geocoder\Provider\Pelias\Pelias; use Geocoder\Provider\Provider; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; final class OpenRouteService extends Pelias implements Provider { @@ -32,10 +32,10 @@ final class OpenRouteService extends Pelias implements Provider private $apiKey; /** - * @param HttpClient $client an HTTP adapter - * @param string $apiKey an API key + * @param ClientInterface $client an HTTP adapter + * @param string $apiKey an API key */ - public function __construct(HttpClient $client, string $apiKey) + public function __construct(ClientInterface $client, string $apiKey) { if (empty($apiKey)) { throw new InvalidCredentials('No API key provided.'); diff --git a/src/Provider/OpenRouteService/Tests/IntegrationTest.php b/src/Provider/OpenRouteService/Tests/IntegrationTest.php index b8ead9580..06eac1573 100644 --- a/src/Provider/OpenRouteService/Tests/IntegrationTest.php +++ b/src/Provider/OpenRouteService/Tests/IntegrationTest.php @@ -14,7 +14,7 @@ use Geocoder\IntegrationTest\ProviderIntegrationTest; use Geocoder\Provider\OpenRouteService\OpenRouteService; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author Tobias Nyholm @@ -29,7 +29,7 @@ class IntegrationTest extends ProviderIntegrationTest protected $testIpv6 = false; - protected function createProvider(HttpClient $httpClient) + protected function createProvider(ClientInterface $httpClient) { return new OpenRouteService($httpClient, $this->getApiKey()); } diff --git a/src/Provider/Pelias/Pelias.php b/src/Provider/Pelias/Pelias.php index c5d1b80cf..8eb2da718 100644 --- a/src/Provider/Pelias/Pelias.php +++ b/src/Provider/Pelias/Pelias.php @@ -22,7 +22,7 @@ use Geocoder\Query\ReverseQuery; use Geocoder\Http\Provider\AbstractHttpProvider; use Geocoder\Provider\Provider; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; class Pelias extends AbstractHttpProvider implements Provider { @@ -37,11 +37,11 @@ class Pelias extends AbstractHttpProvider implements Provider private $version; /** - * @param HttpClient $client an HTTP adapter - * @param string $root url of Pelias API - * @param int $version version of Pelias API + * @param ClientInterface $client an HTTP adapter + * @param string $root url of Pelias API + * @param int $version version of Pelias API */ - public function __construct(HttpClient $client, string $root, int $version = 1) + public function __construct(ClientInterface $client, string $root, int $version = 1) { $this->root = sprintf('%s/v%d', rtrim($root, '/'), $version); $this->version = $version; diff --git a/src/Provider/Pelias/Tests/IntegrationTest.php b/src/Provider/Pelias/Tests/IntegrationTest.php index 4a10aefb0..fd905fa7a 100644 --- a/src/Provider/Pelias/Tests/IntegrationTest.php +++ b/src/Provider/Pelias/Tests/IntegrationTest.php @@ -14,7 +14,7 @@ use Geocoder\IntegrationTest\ProviderIntegrationTest; use Geocoder\Provider\Pelias\Pelias; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author Tobias Nyholm @@ -32,7 +32,7 @@ class IntegrationTest extends ProviderIntegrationTest protected $testIpv6 = false; - protected function createProvider(HttpClient $httpClient) + protected function createProvider(ClientInterface $httpClient) { return new Pelias($httpClient, 'http://localhost/'); } diff --git a/src/Provider/Photon/Photon.php b/src/Provider/Photon/Photon.php index e3f2cd186..36f5ef181 100644 --- a/src/Provider/Photon/Photon.php +++ b/src/Provider/Photon/Photon.php @@ -23,7 +23,7 @@ use Geocoder\Http\Provider\AbstractHttpProvider; use Geocoder\Provider\Provider; use Geocoder\Provider\Photon\Model\PhotonAddress; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author Niklas Närhinen @@ -37,20 +37,20 @@ final class Photon extends AbstractHttpProvider implements Provider private $rootUrl; /** - * @param HttpClient $client an HTTP client + * @param ClientInterface $client an HTTP client * * @return Photon */ - public static function withKomootServer(HttpClient $client): self + public static function withKomootServer(ClientInterface $client): self { return new self($client, 'https://photon.komoot.io'); } /** - * @param HttpClient $client an HTTP client - * @param string $rootUrl Root URL of the photon server + * @param ClientInterface $client an HTTP client + * @param string $rootUrl Root URL of the photon server */ - public function __construct(HttpClient $client, $rootUrl) + public function __construct(ClientInterface $client, $rootUrl) { parent::__construct($client); diff --git a/src/Provider/Photon/Tests/IntegrationTest.php b/src/Provider/Photon/Tests/IntegrationTest.php index 182c1d871..f6aa43fdb 100644 --- a/src/Provider/Photon/Tests/IntegrationTest.php +++ b/src/Provider/Photon/Tests/IntegrationTest.php @@ -12,7 +12,7 @@ use Geocoder\IntegrationTest\ProviderIntegrationTest; use Geocoder\Provider\Photon\Photon; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author Tobias Nyholm @@ -32,7 +32,7 @@ class IntegrationTest extends ProviderIntegrationTest 'testReverseQueryWithNoResults' => 'Photon API returns "Atlas Buoy 0.00E 0.00N" for reverse query at 0,0.', ]; - protected function createProvider(HttpClient $httpClient) + protected function createProvider(ClientInterface $httpClient) { return Photon::withKomootServer($httpClient, 'Geocoder PHP/Photon Provider/Integration Test'); } diff --git a/src/Provider/PickPoint/PickPoint.php b/src/Provider/PickPoint/PickPoint.php index 8cfae0a5c..987342ba5 100644 --- a/src/Provider/PickPoint/PickPoint.php +++ b/src/Provider/PickPoint/PickPoint.php @@ -22,7 +22,7 @@ use Geocoder\Query\ReverseQuery; use Geocoder\Http\Provider\AbstractHttpProvider; use Geocoder\Provider\Provider; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author Vladimir Kalinkin @@ -40,10 +40,10 @@ final class PickPoint extends AbstractHttpProvider implements Provider private $apiKey; /** - * @param HttpClient $client an HTTP adapter - * @param string $apiKey an API key + * @param ClientInterface $client an HTTP adapter + * @param string $apiKey an API key */ - public function __construct(HttpClient $client, string $apiKey) + public function __construct(ClientInterface $client, string $apiKey) { if (empty($apiKey)) { throw new InvalidCredentials('No API key provided.'); diff --git a/src/Provider/PickPoint/Tests/IntegrationTest.php b/src/Provider/PickPoint/Tests/IntegrationTest.php index 6bb7f5ba2..d19e397fe 100644 --- a/src/Provider/PickPoint/Tests/IntegrationTest.php +++ b/src/Provider/PickPoint/Tests/IntegrationTest.php @@ -12,14 +12,14 @@ use Geocoder\IntegrationTest\ProviderIntegrationTest; use Geocoder\Provider\PickPoint\PickPoint; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author Vladimir Kalinkin */ class IntegrationTest extends ProviderIntegrationTest { - protected function createProvider(HttpClient $httpClient) + protected function createProvider(ClientInterface $httpClient) { return new PickPoint($httpClient, $this->getApiKey()); } diff --git a/src/Provider/TomTom/Tests/IntegrationTest.php b/src/Provider/TomTom/Tests/IntegrationTest.php index 1e5e798b5..155e75735 100644 --- a/src/Provider/TomTom/Tests/IntegrationTest.php +++ b/src/Provider/TomTom/Tests/IntegrationTest.php @@ -14,7 +14,7 @@ use Geocoder\IntegrationTest\ProviderIntegrationTest; use Geocoder\Provider\TomTom\TomTom; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author Tobias Nyholm @@ -29,7 +29,7 @@ class IntegrationTest extends ProviderIntegrationTest protected $testIpv6 = false; - protected function createProvider(HttpClient $httpClient) + protected function createProvider(ClientInterface $httpClient) { return new TomTom($httpClient, $this->getApiKey()); } diff --git a/src/Provider/TomTom/TomTom.php b/src/Provider/TomTom/TomTom.php index 540757b16..ad0e50132 100644 --- a/src/Provider/TomTom/TomTom.php +++ b/src/Provider/TomTom/TomTom.php @@ -21,7 +21,7 @@ use Geocoder\Query\ReverseQuery; use Geocoder\Http\Provider\AbstractHttpProvider; use Geocoder\Provider\Provider; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author Antoine Corcy @@ -44,10 +44,10 @@ final class TomTom extends AbstractHttpProvider implements Provider private $apiKey; /** - * @param HttpClient $client an HTTP adapter - * @param string $apiKey an API key + * @param ClientInterface $client an HTTP adapter + * @param string $apiKey an API key */ - public function __construct(HttpClient $client, string $apiKey) + public function __construct(ClientInterface $client, string $apiKey) { if (empty($apiKey)) { throw new InvalidCredentials('No API key provided.'); diff --git a/src/Provider/Yandex/README.md b/src/Provider/Yandex/README.md index 31d6ef929..9392f9d7d 100644 --- a/src/Provider/Yandex/README.md +++ b/src/Provider/Yandex/README.md @@ -8,7 +8,7 @@ [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE) This is the Yandex provider from the PHP Geocoder. This is a **READ ONLY** repository. See the -[main repo](https://github.com/geocoder-php/Geocoder) for information and documentation. +[main repo](https://github.com/geocoder-php/Geocoder) for information and documentation. ### Install @@ -21,7 +21,7 @@ composer require geocoder-php/yandex-provider The API now requires an API key. [See here for more information](https://yandex.ru/blog/mapsapi/novye-pravila-dostupa-k-api-kart?from=tech_pp). ```php -$httpClient = new \Http\Adapter\Guzzle6\Client(); +$httpClient = new \GuzzleHttp\Client(); $provider = new \Geocoder\Provider\Yandex\Yandex($httpClient, null, '); $result = $geocoder->geocodeQuery(GeocodeQuery::create('ул.Ленина, 19, Минск 220030, Республика Беларусь')); @@ -31,12 +31,12 @@ $result = $geocoder->reverseQuery(ReverseQuery::fromCoordinates(...)); ### Note The default language-locale is `ru-RU`, you can choose between `uk-UA`, `be-BY`, -`en-US`, `en-BR` and `tr-TR`. +`en-US`, `en-BR` and `tr-TR`. It's possible to precise the toponym to get more accurate result for reverse geocoding: `house`, `street`, `metro`, `district` and `locality`. ### Contribute -Contributions are very welcome! Send a pull request to the [main repository](https://github.com/geocoder-php/Geocoder) or +Contributions are very welcome! Send a pull request to the [main repository](https://github.com/geocoder-php/Geocoder) or report any issues you find on the [issue tracker](https://github.com/geocoder-php/Geocoder/issues). diff --git a/src/Provider/Yandex/Tests/IntegrationTest.php b/src/Provider/Yandex/Tests/IntegrationTest.php index e9344aed6..2d88327db 100644 --- a/src/Provider/Yandex/Tests/IntegrationTest.php +++ b/src/Provider/Yandex/Tests/IntegrationTest.php @@ -14,7 +14,7 @@ use Geocoder\IntegrationTest\ProviderIntegrationTest; use Geocoder\Provider\Yandex\Yandex; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author Tobias Nyholm @@ -34,7 +34,7 @@ class IntegrationTest extends ProviderIntegrationTest protected $testIpv6 = false; - protected function createProvider(HttpClient $httpClient) + protected function createProvider(ClientInterface $httpClient) { return new Yandex($httpClient); } diff --git a/src/Provider/Yandex/Yandex.php b/src/Provider/Yandex/Yandex.php index b057cfa8a..bd977a339 100644 --- a/src/Provider/Yandex/Yandex.php +++ b/src/Provider/Yandex/Yandex.php @@ -21,7 +21,7 @@ use Geocoder\Provider\Yandex\Model\YandexAddress; use Geocoder\Query\GeocodeQuery; use Geocoder\Query\ReverseQuery; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; /** * @author Antoine Corcy @@ -49,11 +49,11 @@ final class Yandex extends AbstractHttpProvider implements Provider private $apiKey; /** - * @param HttpClient $client an HTTP adapter - * @param string $toponym toponym biasing only for reverse geocoding (optional) - * @param string|null $apiKey API Key + * @param ClientInterface $client an HTTP adapter + * @param string $toponym toponym biasing only for reverse geocoding (optional) + * @param string|null $apiKey API Key */ - public function __construct(HttpClient $client, string $toponym = null, string $apiKey = null) + public function __construct(ClientInterface $client, string $toponym = null, string $apiKey = null) { parent::__construct($client);