From 94b301e16ef53a0c2d9e31dc4839390064ece507 Mon Sep 17 00:00:00 2001 From: Pulkit Jalan Date: Thu, 22 Aug 2024 06:13:54 +0100 Subject: [PATCH] fix more --- src/Drivers/IPStackDriver.php | 6 +++--- src/IPGeolocationManager.php | 14 +++++++------- src/IPGeolocationServiceProvider.php | 17 +++++++++-------- tests/Drivers/IPStackDriverTest.php | 20 ++++++++++---------- tests/IPGeolocationUpdaterTest.php | 6 +++--- 5 files changed, 32 insertions(+), 31 deletions(-) diff --git a/src/Drivers/IPStackDriver.php b/src/Drivers/IPStackDriver.php index f29ffb1..a9392ae 100644 --- a/src/Drivers/IPStackDriver.php +++ b/src/Drivers/IPStackDriver.php @@ -1,11 +1,11 @@ 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')) { @@ -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']); }); } @@ -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']); }); } @@ -67,8 +67,9 @@ protected function registerUpdateCommand() public function provides() { return [ - IPGeoLocation::class, + IPGeolocation::class, UpdateCommand::class, + 'ipGeolocation', ]; } } diff --git a/tests/Drivers/IPStackDriverTest.php b/tests/Drivers/IPStackDriverTest.php index 1ed42db..2707cc9 100644 --- a/tests/Drivers/IPStackDriverTest.php +++ b/tests/Drivers/IPStackDriverTest.php @@ -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 = [ @@ -36,7 +36,7 @@ ) ); - $ip = new IPGeoLocation($config, $client); + $ip = new IPGeolocation($config, $client); $ip = $ip->setIp($this->validIp); expect($ip->get())->toEqual( @@ -74,7 +74,7 @@ ) ); - $ip = new IPGeoLocation($config, $client); + $ip = new IPGeolocation($config, $client); $ip = $ip->setIp($this->validIp); expect($ip->get())->toEqual( @@ -101,7 +101,7 @@ ]; $this->expectException(IPGeolocationException::class); - $ip = new IPGeoLocation($config); + $ip = new IPGeolocation($config); $ip = $ip->setIp($this->validIp); $ip->getRaw(); @@ -114,7 +114,7 @@ $this->expectException(InvalidCredentialsException::class); - $ip = new IPGeoLocation($config); + $ip = new IPGeolocation($config); $ip = $ip->setIp($this->validIp); $ip->get(); @@ -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(); @@ -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(); @@ -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(); diff --git a/tests/IPGeolocationUpdaterTest.php b/tests/IPGeolocationUpdaterTest.php index 367142e..9186005 100644 --- a/tests/IPGeolocationUpdaterTest.php +++ b/tests/IPGeolocationUpdaterTest.php @@ -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);