Skip to content

Commit 77dc34a

Browse files
authored
Expect a PSR-18 client instead of a PHP-HTTP client (#1110)
* Expect a PSR-18 client instead of a PHP-HTTP client * Update integration tests
1 parent 7c7897a commit 77dc34a

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

AlgoliaPlaces.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
use Geocoder\Provider\Provider;
2323
use Geocoder\Query\GeocodeQuery;
2424
use Geocoder\Query\ReverseQuery;
25-
use Http\Client\HttpClient;
25+
use Psr\Http\Client\ClientInterface;
2626
use Psr\Http\Message\RequestInterface;
2727

2828
class AlgoliaPlaces extends AbstractHttpProvider implements Provider
@@ -53,10 +53,10 @@ class AlgoliaPlaces extends AbstractHttpProvider implements Provider
5353
/** @var GeocodeQuery */
5454
private $query;
5555

56-
/** @var HttpClient */
56+
/** @var ClientInterface */
5757
private $client;
5858

59-
public function __construct(HttpClient $client, string $apiKey = null, string $appId = null)
59+
public function __construct(ClientInterface $client, string $apiKey = null, string $appId = null)
6060
{
6161
parent::__construct($client);
6262

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)
1010

1111
This is the Algolia Places provider from the PHP Geocoder. This is a **READ ONLY** repository. See the
12-
[main repo](https://github.com/geocoder-php/Geocoder) for information and documentation.
12+
[main repo](https://github.com/geocoder-php/Geocoder) for information and documentation.
1313

1414
## Install
1515

@@ -34,11 +34,11 @@ You should set a locale on the query. If it is missing, results may not be as co
3434
use Geocoder\Query\GeocodeQuery;
3535
use Geocoder\Query\ReverseQuery;
3636

37-
$httpClient = new \Http\Adapter\Guzzle6\Client();
37+
$httpClient = new \GuzzleHttp\Client();
3838

3939
// Unauthenticated
4040
$provider = new \Geocoder\Provider\AlgoliaPlaces\AlgoliaPlaces($httpClient);
41-
// Authenticated
41+
// Authenticated
4242
$provider = new \Geocoder\Provider\AlgoliaPlaces\AlgoliaPlaces($httpClient, '<your-key>', '<your-app-id>');
4343

4444
$geocoder = new \Geocoder\StatefulGeocoder($provider, 'en');
@@ -48,5 +48,5 @@ $result = $geocoder->geocodeQuery(GeocodeQuery::create('Paris')->withLocale('fr-
4848

4949
## Contribute
5050

51-
Contributions are very welcome! Send a pull request to the [main repository](https://github.com/geocoder-php/Geocoder) or
51+
Contributions are very welcome! Send a pull request to the [main repository](https://github.com/geocoder-php/Geocoder) or
5252
report any issues you find on the [issue tracker](https://github.com/geocoder-php/Geocoder/issues).

Tests/IntegrationTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
use Geocoder\Model\Country;
2222
use Geocoder\Query\GeocodeQuery;
2323
use Geocoder\Query\ReverseQuery;
24-
use Http\Client\HttpClient;
25-
use Http\Discovery\HttpClientDiscovery;
24+
use Http\Discovery\Psr18ClientDiscovery;
25+
use Psr\Http\Client\ClientInterface;
2626

2727
/**
2828
* @author Sébastien Barré <sebastien@sheub.eu>
@@ -35,7 +35,7 @@ class IntegrationTest extends ProviderIntegrationTest
3535

3636
protected $testReverse = false;
3737

38-
protected function createProvider(HttpClient $httpClient)
38+
protected function createProvider(ClientInterface $httpClient)
3939
{
4040
return new AlgoliaPlaces($httpClient, $this->getApiKey(), $this->getAppId());
4141
}
@@ -53,9 +53,9 @@ protected function getCacheDir()
5353
private function getCachedHttpClient()
5454
{
5555
try {
56-
$client = HttpClientDiscovery::find();
57-
} catch (\Http\Discovery\NotFoundException $e) {
58-
$client = $this->getMockForAbstractClass(HttpClient::class);
56+
$client = Psr18ClientDiscovery::find();
57+
} catch (\Http\Discovery\Exception\NotFoundException $e) {
58+
$client = $this->getMockForAbstractClass(ClientInterface::class);
5959

6060
$client
6161
->expects($this->any())

0 commit comments

Comments
 (0)