Skip to content

Commit 79f3603

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 fc631c4 commit 79f3603

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

Here.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
use Geocoder\Query\Query;
2626
use Geocoder\Query\GeocodeQuery;
2727
use Geocoder\Query\ReverseQuery;
28-
use Http\Client\HttpClient;
28+
use Psr\Http\Client\ClientInterface;
2929

3030
/**
3131
* @author Sébastien Barré <[email protected]>
@@ -116,12 +116,12 @@ final class Here extends AbstractHttpProvider implements Provider
116116
private $apiKey;
117117

118118
/**
119-
* @param HttpClient $client an HTTP adapter
120-
* @param string $appId an App ID
121-
* @param string $appCode an App code
122-
* @param bool $useCIT use Customer Integration Testing environment (CIT) instead of production
119+
* @param ClientInterface $client an HTTP adapter
120+
* @param string $appId an App ID
121+
* @param string $appCode an App code
122+
* @param bool $useCIT use Customer Integration Testing environment (CIT) instead of production
123123
*/
124-
public function __construct(HttpClient $client, string $appId = null, string $appCode = null, bool $useCIT = false)
124+
public function __construct(ClientInterface $client, string $appId = null, string $appCode = null, bool $useCIT = false)
125125
{
126126
$this->appId = $appId;
127127
$this->appCode = $appCode;
@@ -130,7 +130,7 @@ public function __construct(HttpClient $client, string $appId = null, string $ap
130130
parent::__construct($client);
131131
}
132132

133-
public static function createUsingApiKey(HttpClient $client, string $apiKey, bool $useCIT = false): self
133+
public static function createUsingApiKey(ClientInterface $client, string $apiKey, bool $useCIT = false): self
134134
{
135135
$client = new self($client, null, null, $useCIT);
136136
$client->apiKey = $apiKey;

Readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ composer require geocoder-php/here-provider
2424
New applications on the Here platform use the `api_key` authentication method.
2525

2626
```php
27-
$httpClient = new \Http\Adapter\Guzzle6\Client();
27+
$httpClient = new \GuzzleHttp\Client();
2828

2929
// You must provide an API key
3030
$provider = \Geocoder\Provider\Here\Here::createUsingApiKey($httpClient, 'your-api-key');
@@ -35,7 +35,7 @@ $result = $geocoder->geocodeQuery(GeocodeQuery::create('Buckingham Palace, Londo
3535
If you're using the legacy `app_code` authentication method, use the constructor on the provider like so:
3636

3737
```php
38-
$httpClient = new \Http\Adapter\Guzzle6\Client();
38+
$httpClient = new \GuzzleHttp\Client();
3939

4040
// You must provide both the app_id and app_code
4141
$provider = new \Geocoder\Provider\Here\Here($httpClient, 'app-id', 'app-code');

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é <[email protected]>
@@ -33,7 +33,7 @@ class IntegrationTest extends ProviderIntegrationTest
3333

3434
protected $testIpv6 = false;
3535

36-
protected function createProvider(HttpClient $httpClient, bool $useCIT = false)
36+
protected function createProvider(ClientInterface $httpClient, bool $useCIT = false)
3737
{
3838
return Here::createUsingApiKey($httpClient, $this->getApiKey(), $useCIT);
3939
}
@@ -51,9 +51,9 @@ protected function getCacheDir()
5151
private function getCachedHttpClient()
5252
{
5353
try {
54-
$client = HttpClientDiscovery::find();
55-
} catch (\Http\Discovery\NotFoundException $e) {
56-
$client = $this->getMockForAbstractClass(HttpClient::class);
54+
$client = Psr18ClientDiscovery::find();
55+
} catch (\Http\Discovery\Exception\NotFoundException $e) {
56+
$client = $this->getMockForAbstractClass(ClientInterface::class);
5757

5858
$client
5959
->expects($this->any())

0 commit comments

Comments
 (0)