Skip to content

Commit dda7128

Browse files
authored
Changed order of constructor arguments (#2)
* changed order of constructor parameters * updated comment
1 parent 1a7bb74 commit dda7128

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use Nyholm\Psr7\Factory\Psr17Factory;
2424

2525
$httpClient = new Psr18Client();
2626
$psr17Factory = new Psr17Factory();
27-
$ipdata = new Ipdata($httpClient, 'my_api_key', $psr17Factory);
27+
$ipdata = new Ipdata('my_api_key', $httpClient, $psr17Factory);
2828
```
2929

3030
## How to use

src/Ipdata.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ class Ipdata
3737
private $requestFactory;
3838

3939
/**
40-
* Get an instance of the API client. Give it PSR-18 client, an API key and a PSR-17 request factory.
40+
* Get an instance of the API client. Give it an API key, a PSR-18 client and a PSR-17 request factory.
4141
*
4242
* @param ClientInterface|null $httpClient if null, we will try to use php-http/discovery to find an installed client
4343
* @param RequestFactoryInterface|null $requestFactory if null, we will try to use php-http/discovery to find an installed factory
4444
*/
45-
public function __construct(ClientInterface $httpClient = null, ?string $apiKey = null, RequestFactoryInterface $requestFactory = null)
45+
public function __construct(string $apiKey, ClientInterface $httpClient = null, RequestFactoryInterface $requestFactory = null)
4646
{
4747
if (null === $httpClient) {
4848
if (!class_exists(Psr18ClientDiscovery::class)) {

tests/IpdataTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,13 @@ public function testParseInvalidJsonResponse()
137137

138138
public function testConstructWithDiscovery()
139139
{
140-
$ipdata = new Ipdata(null, 'secret_key');
140+
$ipdata = new Ipdata('secret_key');
141141
$this->assertInstanceOf(Ipdata::class, $ipdata);
142142
}
143143

144144
private function createIpdata(ClientInterface $httpClient): Ipdata
145145
{
146-
return new Ipdata($httpClient, 'secret_key', new Psr17Factory());
146+
return new Ipdata('secret_key', $httpClient, new Psr17Factory());
147147
}
148148

149149
private function createResponse(array $data = [], int $statusCode = 200): ResponseInterface

0 commit comments

Comments
 (0)