Skip to content

Commit

Permalink
fix more
Browse files Browse the repository at this point in the history
  • Loading branch information
pulkitjalan committed Aug 22, 2024
1 parent 519398a commit 94b301e
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 31 deletions.
6 changes: 3 additions & 3 deletions src/Drivers/IPStackDriver.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

namespace PulkitJalan\IPGeoLocation\Drivers;
namespace PulkitJalan\IPGeolocation\Drivers;

use Illuminate\Support\Arr;
use GuzzleHttp\Client as GuzzleClient;
use GuzzleHttp\Exception\GuzzleException;
use PulkitJalan\IPGeoLocation\Exceptions\InvalidCredentialsException;
use PulkitJalan\IPGeolocation\Exceptions\InvalidCredentialsException;

class IPStackDriver extends AbstractIPGeolocationDriver implements IPGeolocationInterface
{
Expand Down Expand Up @@ -53,7 +53,7 @@ public function get($ip)
}

/**
* Get the raw IPGeoLocation info using ipstack.
* Get the raw IPGeolocation info using ipstack.
*
* @param string $ip
* @return array
Expand Down
14 changes: 7 additions & 7 deletions src/IPGeolocationManager.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?php

namespace PulkitJalan\IPGeoLocation;
namespace PulkitJalan\IPGeolocation;

use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use GuzzleHttp\Client as GuzzleClient;
use PulkitJalan\IPGeoLocation\Drivers\IPApiDriver;
use PulkitJalan\IPGeoLocation\Drivers\IPStackDriver;
use PulkitJalan\IPGeoLocation\Drivers\MaxmindApiDriver;
use PulkitJalan\IPGeoLocation\Drivers\MaxmindDatabaseDriver;
use PulkitJalan\IPGeoLocation\Exceptions\InvalidDriverException;
use PulkitJalan\IPGeoLocation\Drivers\AbstractIPGeolocationDriver;
use PulkitJalan\IPGeolocation\Drivers\IPApiDriver;
use PulkitJalan\IPGeolocation\Drivers\IPStackDriver;
use PulkitJalan\IPGeolocation\Drivers\MaxmindApiDriver;
use PulkitJalan\IPGeolocation\Drivers\MaxmindDatabaseDriver;
use PulkitJalan\IPGeolocation\Exceptions\InvalidDriverException;
use PulkitJalan\IPGeolocation\Drivers\AbstractIPGeolocationDriver;

class IPGeolocationManager
{
Expand Down
17 changes: 9 additions & 8 deletions src/IPGeolocationServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace PulkitJalan\IPGeoLocation;
namespace PulkitJalan\IPGeolocation;

use Illuminate\Support\ServiceProvider;
use PulkitJalan\IPGeoLocation\Console\UpdateCommand;
use PulkitJalan\IPGeolocation\Console\UpdateCommand;

class IPGeolocationServiceProvider extends ServiceProvider
{
Expand All @@ -13,11 +13,11 @@ class IPGeolocationServiceProvider extends ServiceProvider
public function boot()
{
$this->app['ipGeolocation'] = function ($app) {
return $app['PulkitJalan\IPGeoLocation\IPGeoLocation'];
return $app[IPGeolocation::class];
};

if ($this->app->runningInConsole()) {
$this->commands(['PulkitJalan\IPGeoLocation\Console\UpdateCommand']);
$this->commands([UpdateCommand::class]);
}

if (function_exists('config_path')) {
Expand All @@ -44,8 +44,8 @@ public function register()
*/
protected function registerIPGeolocation()
{
$this->app->singleton('PulkitJalan\IPGeoLocation\IPGeoLocation', function ($app) {
return new IPGeoLocation($app['config']['ip-geolocation']);
$this->app->singleton(IPGeolocation::class, function ($app) {
return new IPGeolocation($app['config']['ip-geolocation']);
});
}

Expand All @@ -54,7 +54,7 @@ protected function registerIPGeolocation()
*/
protected function registerUpdateCommand()
{
$this->app->singleton('PulkitJalan\IPGeoLocation\Console\UpdateCommand', function ($app) {
$this->app->singleton(UpdateCommand::class, function ($app) {
return new UpdateCommand($app['config']['ip-geolocation']);
});
}
Expand All @@ -67,8 +67,9 @@ protected function registerUpdateCommand()
public function provides()
{
return [
IPGeoLocation::class,
IPGeolocation::class,
UpdateCommand::class,
'ipGeolocation',
];
}
}
20 changes: 10 additions & 10 deletions tests/Drivers/IPStackDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Response;
use PulkitJalan\IPGeoLocation\IPGeoLocation;
use PulkitJalan\IPGeoLocation\Exceptions\IPGeolocationException;
use PulkitJalan\IPGeoLocation\Exceptions\InvalidCredentialsException;
use PulkitJalan\IPGeolocation\IPGeolocation;
use PulkitJalan\IPGeolocation\Exceptions\IPGeolocationException;
use PulkitJalan\IPGeolocation\Exceptions\InvalidCredentialsException;

test('ipstack', function () {
$config = [
Expand Down Expand Up @@ -36,7 +36,7 @@
)
);

$ip = new IPGeoLocation($config, $client);
$ip = new IPGeolocation($config, $client);
$ip = $ip->setIp($this->validIp);

expect($ip->get())->toEqual(
Expand Down Expand Up @@ -74,7 +74,7 @@
)
);

$ip = new IPGeoLocation($config, $client);
$ip = new IPGeolocation($config, $client);
$ip = $ip->setIp($this->validIp);

expect($ip->get())->toEqual(
Expand All @@ -101,7 +101,7 @@
];
$this->expectException(IPGeolocationException::class);

$ip = new IPGeoLocation($config);
$ip = new IPGeolocation($config);
$ip = $ip->setIp($this->validIp);

$ip->getRaw();
Expand All @@ -114,7 +114,7 @@

$this->expectException(InvalidCredentialsException::class);

$ip = new IPGeoLocation($config);
$ip = new IPGeolocation($config);
$ip = $ip->setIp($this->validIp);

$ip->get();
Expand All @@ -141,7 +141,7 @@
new Response(200, [], json_encode(['city' => 'test city']))
);

$ip = new IPGeoLocation($config, $client);
$ip = new IPGeolocation($config, $client);
$ip = $ip->setIp($this->validIp);

$ip->get();
Expand Down Expand Up @@ -169,7 +169,7 @@
new Response(200, [], json_encode(['city' => 'test city']))
);

$ip = new IPGeoLocation($config, $client);
$ip = new IPGeolocation($config, $client);
$ip = $ip->setIp($this->validIp);

$ip->get();
Expand Down Expand Up @@ -197,7 +197,7 @@
new Response(200, [], json_encode(['city' => 'test city']))
);

$ip = new IPGeoLocation($config, $client);
$ip = new IPGeolocation($config, $client);
$ip = $ip->setIp($this->validIp);

$ip->get();
Expand Down
6 changes: 3 additions & 3 deletions tests/IPGeolocationUpdaterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

use GuzzleHttp\Psr7\Response;
use GuzzleHttp\Client as GuzzleClient;
use PulkitJalan\IPGeoLocation\IPGeolocationUpdater;
use PulkitJalan\IPGeoLocation\Exceptions\InvalidDatabaseException;
use PulkitJalan\IPGeoLocation\Exceptions\InvalidCredentialsException;
use PulkitJalan\IPGeolocation\IPGeolocationUpdater;
use PulkitJalan\IPGeolocation\Exceptions\InvalidDatabaseException;
use PulkitJalan\IPGeolocation\Exceptions\InvalidCredentialsException;

test('no database', function () {
$this->expectException(InvalidDatabaseException::class);
Expand Down

0 comments on commit 94b301e

Please sign in to comment.