diff --git a/config/ip-intel.php b/config/ip-intel.php index b90e331..3017ae1 100644 --- a/config/ip-intel.php +++ b/config/ip-intel.php @@ -57,10 +57,10 @@ 'sources' => [ 'ipapi' => [ - 'key' => env('IP_INTEL_IPAPI_KEY'), + 'key' => env('IP_INTEL_IPAPI_KEY'), 'base_url' => env('IP_INTEL_IPAPI_URL', 'https://api.ipapi.com/api'), - 'timeout' => (int) env('IP_INTEL_IPAPI_TIMEOUT', 5), - 'retries' => (int) env('IP_INTEL_IPAPI_RETRIES', 2), + 'timeout' => (int) env('IP_INTEL_IPAPI_TIMEOUT', 5), + 'retries' => (int) env('IP_INTEL_IPAPI_RETRIES', 2), ], ], @@ -78,9 +78,9 @@ 'cache' => [ 'enabled' => env('IP_INTEL_CACHE', true), - 'store' => env('IP_INTEL_CACHE_STORE'), - 'ttl' => (int) env('IP_INTEL_CACHE_TTL', 1440), - 'prefix' => 'laranail.ip-intel', + 'store' => env('IP_INTEL_CACHE_STORE'), + 'ttl' => (int) env('IP_INTEL_CACHE_TTL', 1440), + 'prefix' => 'laranail.ip-intel', ], /* @@ -100,9 +100,9 @@ */ 'api' => [ - 'enabled' => env('IP_INTEL_API', false), - 'prefix' => env('IP_INTEL_API_PREFIX', 'api/ip-intel'), - 'version' => 'v1', + 'enabled' => env('IP_INTEL_API', false), + 'prefix' => env('IP_INTEL_API_PREFIX', 'api/ip-intel'), + 'version' => 'v1', 'middleware' => ['api', 'throttle:60,1'], ], diff --git a/rector.php b/rector.php index 1eb784c..ee28544 100644 --- a/rector.php +++ b/rector.php @@ -17,10 +17,10 @@ * the generator emits byte for byte, so a Rector rewrite would put the two permanently at odds. */ return RectorConfig::configure() - ->withPaths([__DIR__ . '/src', __DIR__ . '/tests']) + ->withPaths([__DIR__.'/src', __DIR__.'/tests']) ->withSkip([ - __DIR__ . '/vendor', - __DIR__ . '/tests/Fixtures', + __DIR__.'/vendor', + __DIR__.'/tests/Fixtures', ]) ->withPhpSets(php84: true) ->withSets([ diff --git a/src/Adapters/EdgeHeader/EdgeHeaderDriver.php b/src/Adapters/EdgeHeader/EdgeHeaderDriver.php index 69784a3..1b95f3d 100644 --- a/src/Adapters/EdgeHeader/EdgeHeaderDriver.php +++ b/src/Adapters/EdgeHeader/EdgeHeaderDriver.php @@ -32,7 +32,7 @@ final readonly class EdgeHeaderDriver implements ResolvesCountry { /** - * @param list $headers in priority order + * @param list $headers in priority order */ public function __construct( private ?Request $request, diff --git a/src/Adapters/IpApi/IpApiDriver.php b/src/Adapters/IpApi/IpApiDriver.php index ea9022f..03ac3b1 100644 --- a/src/Adapters/IpApi/IpApiDriver.php +++ b/src/Adapters/IpApi/IpApiDriver.php @@ -4,20 +4,20 @@ namespace Simtabi\Laranail\IpIntel\Adapters\IpApi; -use Throwable; +use Illuminate\Http\Client\Factory as HttpFactory; use Psr\Log\LoggerInterface; -use Simtabi\Laranail\IpIntel\Data\AsnInfo; -use Simtabi\Laranail\IpIntel\Data\PlaceInfo; use Simtabi\Laranail\Atlas\Core\Geo\Coordinates; -use Simtabi\Laranail\IpIntel\Data\ThreatSignals; -use Illuminate\Http\Client\Factory as HttpFactory; use Simtabi\Laranail\Atlas\Core\Network\IpAddress; +use Simtabi\Laranail\IpIntel\Adapters\Local\AtlasDriver; +use Simtabi\Laranail\IpIntel\Contracts\DetectsThreats; use Simtabi\Laranail\IpIntel\Contracts\ResolvesAsn; use Simtabi\Laranail\IpIntel\Contracts\ResolvesCity; -use Simtabi\Laranail\IpIntel\Contracts\DetectsThreats; use Simtabi\Laranail\IpIntel\Contracts\ResolvesCountry; -use Simtabi\Laranail\IpIntel\Adapters\Local\AtlasDriver; +use Simtabi\Laranail\IpIntel\Data\AsnInfo; +use Simtabi\Laranail\IpIntel\Data\PlaceInfo; +use Simtabi\Laranail\IpIntel\Data\ThreatSignals; use Simtabi\Laranail\IpIntel\Exceptions\SourceUnavailable; +use Throwable; /** * ipapi.com — the paid tier, for the questions registry data cannot answer. @@ -180,7 +180,7 @@ private function fetch(IpAddress $address): array throw SourceUnavailable::notConfigured($this->name(), 'IP_INTEL_IPAPI_KEY'); } - $key = $this->name() . ':' . $address->address; + $key = $this->name().':'.$address->address; if (isset($this->memo[$key])) { return $this->memo[$key]; @@ -197,12 +197,12 @@ private function fetch(IpAddress $address): array // a parameter the client encodes rather than a string this // class concatenates into a path. ->withUrlParameters(['ip' => $address->address]) - ->get($this->baseUrl . '/{ip}', ['access_key' => $this->accessKey]); + ->get($this->baseUrl.'/{ip}', ['access_key' => $this->accessKey]); } catch (Throwable $e) { // Never the exception's own message: the client embeds the full // request URL, which carries the access key. $this->logger->warning('ip-intel: ipapi request failed', [ - 'ip' => $address->address, + 'ip' => $address->address, 'reason' => $e::class, ]); @@ -211,7 +211,7 @@ private function fetch(IpAddress $address): array if ($response->failed()) { $this->logger->warning('ip-intel: ipapi returned an error status', [ - 'ip' => $address->address, + 'ip' => $address->address, 'status' => $response->status(), ]); diff --git a/src/Adapters/Local/AtlasDriver.php b/src/Adapters/Local/AtlasDriver.php index 637897e..b07c467 100644 --- a/src/Adapters/Local/AtlasDriver.php +++ b/src/Adapters/Local/AtlasDriver.php @@ -4,9 +4,9 @@ namespace Simtabi\Laranail\IpIntel\Adapters\Local; +use Simtabi\Laranail\Atlas\Core\Contracts\IpCountryResolver; use Simtabi\Laranail\Atlas\Core\Network\IpAddress; use Simtabi\Laranail\IpIntel\Contracts\ResolvesCountry; -use Simtabi\Laranail\Atlas\Core\Contracts\IpCountryResolver; /** * `laranail/atlas`' offline registry table. diff --git a/src/Contracts/DetectsThreats.php b/src/Contracts/DetectsThreats.php index de602c9..dae9f2a 100644 --- a/src/Contracts/DetectsThreats.php +++ b/src/Contracts/DetectsThreats.php @@ -4,8 +4,8 @@ namespace Simtabi\Laranail\IpIntel\Contracts; -use Simtabi\Laranail\IpIntel\Data\ThreatSignals; use Simtabi\Laranail\Atlas\Core\Network\IpAddress; +use Simtabi\Laranail\IpIntel\Data\ThreatSignals; /** * A source that can say something about how an address is being used. diff --git a/src/Contracts/ResolvesAsn.php b/src/Contracts/ResolvesAsn.php index dc03e71..580ff66 100644 --- a/src/Contracts/ResolvesAsn.php +++ b/src/Contracts/ResolvesAsn.php @@ -4,8 +4,8 @@ namespace Simtabi\Laranail\IpIntel\Contracts; -use Simtabi\Laranail\IpIntel\Data\AsnInfo; use Simtabi\Laranail\Atlas\Core\Network\IpAddress; +use Simtabi\Laranail\IpIntel\Data\AsnInfo; /** * A source that can name the network an address is announced from. diff --git a/src/Contracts/ResolvesCity.php b/src/Contracts/ResolvesCity.php index 8e6618a..94ae993 100644 --- a/src/Contracts/ResolvesCity.php +++ b/src/Contracts/ResolvesCity.php @@ -4,8 +4,8 @@ namespace Simtabi\Laranail\IpIntel\Contracts; -use Simtabi\Laranail\IpIntel\Data\PlaceInfo; use Simtabi\Laranail\Atlas\Core\Network\IpAddress; +use Simtabi\Laranail\IpIntel\Data\PlaceInfo; /** * A source that can place an address more precisely than its country. diff --git a/src/Data/AsnInfo.php b/src/Data/AsnInfo.php index 35252fa..a9ce926 100644 --- a/src/Data/AsnInfo.php +++ b/src/Data/AsnInfo.php @@ -25,7 +25,7 @@ public function __construct( public function label(): string { - return 'AS' . $this->number . ($this->organisation === null ? '' : ' ' . $this->organisation); + return 'AS'.$this->number.($this->organisation === null ? '' : ' '.$this->organisation); } /** @@ -34,10 +34,10 @@ public function label(): string public function toArray(): array { return [ - 'number' => $this->number, + 'number' => $this->number, 'organisation' => $this->organisation, - 'prefix' => $this->prefix, - 'allocated' => $this->allocated, + 'prefix' => $this->prefix, + 'allocated' => $this->allocated, ]; } } diff --git a/src/Data/IpIntelResult.php b/src/Data/IpIntelResult.php index 90ad95e..00fd722 100644 --- a/src/Data/IpIntelResult.php +++ b/src/Data/IpIntelResult.php @@ -5,9 +5,9 @@ namespace Simtabi\Laranail\IpIntel\Data; use JsonSerializable; -use Simtabi\Laranail\IpIntel\Enums\Outcome; -use Simtabi\Laranail\Atlas\Core\Network\IpAddress; use Simtabi\Laranail\Atlas\Core\Country\CountryRecord; +use Simtabi\Laranail\Atlas\Core\Network\IpAddress; +use Simtabi\Laranail\IpIntel\Enums\Outcome; /** * What the chain found, and how. @@ -34,7 +34,7 @@ final readonly class IpIntelResult implements JsonSerializable { /** - * @param list $sources drivers that contributed, in order + * @param list $sources drivers that contributed, in order */ private function __construct( public IpAddress $address, @@ -50,7 +50,7 @@ private function __construct( ) {} /** - * @param list $sources + * @param list $sources */ public static function found( IpAddress $address, @@ -94,7 +94,7 @@ public static function reserved(IpAddress $address): self /** * Every source was asked and none had an answer. * - * @param list $sources + * @param list $sources */ public static function notFound(IpAddress $address, array $sources = [], bool $madeNetworkCall = false): self { @@ -114,7 +114,7 @@ public static function notFound(IpAddress $address, array $sources = [], bool $m * problem, and treating it as "unknown visitor" is how a broken integration * runs for months. * - * @param list $sources + * @param list $sources */ public static function unavailable(IpAddress $address, string $why, array $sources = []): self { @@ -161,19 +161,19 @@ public function needsAttention(): bool public function toArray(): array { return [ - 'ip' => $this->address->address, - 'outcome' => $this->outcome->value, + 'ip' => $this->address->address, + 'outcome' => $this->outcome->value, 'country_code' => $this->countryCode, - 'country' => $this->country?->name, - 'flag' => $this->country?->flag(), - 'continent' => $this->country?->continent, - 'currencies' => $this->country?->currencies, - 'asn' => $this->asn?->toArray(), - 'place' => $this->place?->toArray(), - 'threats' => $this->threats?->toArray(), - 'sources' => $this->sources, + 'country' => $this->country?->name, + 'flag' => $this->country?->flag(), + 'continent' => $this->country?->continent, + 'currencies' => $this->country?->currencies, + 'asn' => $this->asn?->toArray(), + 'place' => $this->place?->toArray(), + 'threats' => $this->threats?->toArray(), + 'sources' => $this->sources, 'network_call' => $this->madeNetworkCall, - 'message' => $this->message, + 'message' => $this->message, ]; } diff --git a/src/Data/PlaceInfo.php b/src/Data/PlaceInfo.php index 14af881..d3b55c1 100644 --- a/src/Data/PlaceInfo.php +++ b/src/Data/PlaceInfo.php @@ -42,10 +42,10 @@ public function isPrecise(int $withinKm = 50): bool public function toArray(): array { return [ - 'city' => $this->city, - 'region' => $this->region, - 'postcode' => $this->postcode, - 'coordinates' => $this->coordinates?->toArray(), + 'city' => $this->city, + 'region' => $this->region, + 'postcode' => $this->postcode, + 'coordinates' => $this->coordinates?->toArray(), 'accuracy_radius_km' => $this->accuracyRadiusKm, ]; } diff --git a/src/Data/ThreatSignals.php b/src/Data/ThreatSignals.php index 5e6b305..f4bbc63 100644 --- a/src/Data/ThreatSignals.php +++ b/src/Data/ThreatSignals.php @@ -57,13 +57,13 @@ public function isAnonymised(): bool public function toArray(): array { return [ - 'is_proxy' => $this->isProxy, - 'is_vpn' => $this->isVpn, - 'is_tor' => $this->isTor, + 'is_proxy' => $this->isProxy, + 'is_vpn' => $this->isVpn, + 'is_tor' => $this->isTor, 'is_hosting' => $this->isHosting, 'is_crawler' => $this->isCrawler, 'risk_score' => $this->riskScore, - 'source' => $this->source, + 'source' => $this->source, ]; } } diff --git a/src/Enums/Outcome.php b/src/Enums/Outcome.php index 057b05c..d44b86d 100644 --- a/src/Enums/Outcome.php +++ b/src/Enums/Outcome.php @@ -39,7 +39,7 @@ public function isCacheable(): bool { return match ($this) { self::Found, self::Reserved, self::NotFound => true, - self::Unavailable, self::Disabled => false, + self::Unavailable, self::Disabled => false, }; } } diff --git a/src/Exceptions/SourceUnavailable.php b/src/Exceptions/SourceUnavailable.php index b126ff5..5e008f7 100644 --- a/src/Exceptions/SourceUnavailable.php +++ b/src/Exceptions/SourceUnavailable.php @@ -40,7 +40,7 @@ public static function rejected(string $driver, string $why): self { return new self(sprintf( 'The [%s] source rejected the request: %s. This is usually a dead key or an exhausted quota — ' - . 'note that it answers 200 with success:false, so it is not an HTTP error.', + .'note that it answers 200 with success:false, so it is not an HTTP error.', $driver, $why, )); diff --git a/src/Facades/IpIntel.php b/src/Facades/IpIntel.php index 8cdade3..503bb1d 100644 --- a/src/Facades/IpIntel.php +++ b/src/Facades/IpIntel.php @@ -7,10 +7,10 @@ use Closure; use Illuminate\Http\Request; use Illuminate\Support\Facades\Facade; -use Simtabi\Laranail\IpIntel\Data\IpIntelResult; use Simtabi\Laranail\Atlas\Core\Network\IpAddress; -use Simtabi\Laranail\IpIntel\Services\ResolverChain; +use Simtabi\Laranail\IpIntel\Data\IpIntelResult; use Simtabi\Laranail\IpIntel\Services\IpIntelManager; +use Simtabi\Laranail\IpIntel\Services\ResolverChain; /** * @method static IpIntelResult country(IpAddress|string $address) diff --git a/src/Http/Controllers/LookupController.php b/src/Http/Controllers/LookupController.php index 6fb3e56..e0aa3f3 100644 --- a/src/Http/Controllers/LookupController.php +++ b/src/Http/Controllers/LookupController.php @@ -5,11 +5,11 @@ namespace Simtabi\Laranail\IpIntel\Http\Controllers; use Illuminate\Http\JsonResponse; -use Simtabi\Laranail\IpIntel\Enums\Outcome; use Simtabi\Laranail\IpIntel\Data\IpIntelResult; -use Simtabi\Laranail\IpIntel\Services\IpIntelManager; +use Simtabi\Laranail\IpIntel\Enums\Outcome; use Simtabi\Laranail\IpIntel\Http\Requests\LookupRequest; use Simtabi\Laranail\IpIntel\Http\Resources\IpIntelResource; +use Simtabi\Laranail\IpIntel\Services\IpIntelManager; /** * Read-only lookups over HTTP. @@ -61,8 +61,8 @@ private function statusFor(IpIntelResult $result): int { return match ($result->outcome) { Outcome::Unavailable => 503, - Outcome::Disabled => 501, - default => 200, + Outcome::Disabled => 501, + default => 200, }; } } diff --git a/src/Http/Requests/LookupRequest.php b/src/Http/Requests/LookupRequest.php index 563f798..1e53377 100644 --- a/src/Http/Requests/LookupRequest.php +++ b/src/Http/Requests/LookupRequest.php @@ -30,7 +30,7 @@ public function authorize(): bool public function rules(): array { return [ - 'ip' => ['required', 'string', new ValidIp], + 'ip' => ['required', 'string', new ValidIp], 'full' => ['sometimes', 'boolean'], ]; } diff --git a/src/Providers/IpIntelServiceProvider.php b/src/Providers/IpIntelServiceProvider.php index b9ddc9c..36566bf 100644 --- a/src/Providers/IpIntelServiceProvider.php +++ b/src/Providers/IpIntelServiceProvider.php @@ -4,22 +4,22 @@ namespace Simtabi\Laranail\IpIntel\Providers; -use Override; +use Illuminate\Contracts\Cache\Factory as CacheFactory; +use Illuminate\Contracts\Config\Repository as ConfigRepository; +use Illuminate\Contracts\Foundation\Application; +use Illuminate\Http\Client\Factory as HttpFactory; use Illuminate\Http\Request; -use Psr\Log\LoggerInterface; use Illuminate\Support\Facades\Route; -use Simtabi\Laranail\Package\Tools\Package; -use Illuminate\Contracts\Foundation\Application; +use Override; +use Psr\Log\LoggerInterface; +use Simtabi\Laranail\Atlas\Core\Contracts\IpCountryResolver; use Simtabi\Laranail\Atlas\Services\AtlasService; -use Illuminate\Http\Client\Factory as HttpFactory; -use Simtabi\Laranail\IpIntel\Support\IpIntelConfig; -use Simtabi\Laranail\IpIntel\Services\IpIntelManager; -use Illuminate\Contracts\Cache\Factory as CacheFactory; +use Simtabi\Laranail\IpIntel\Adapters\EdgeHeader\EdgeHeaderDriver; use Simtabi\Laranail\IpIntel\Adapters\IpApi\IpApiDriver; use Simtabi\Laranail\IpIntel\Adapters\Local\AtlasDriver; -use Simtabi\Laranail\Atlas\Core\Contracts\IpCountryResolver; -use Illuminate\Contracts\Config\Repository as ConfigRepository; -use Simtabi\Laranail\IpIntel\Adapters\EdgeHeader\EdgeHeaderDriver; +use Simtabi\Laranail\IpIntel\Services\IpIntelManager; +use Simtabi\Laranail\IpIntel\Support\IpIntelConfig; +use Simtabi\Laranail\Package\Tools\Package; use Simtabi\Laranail\Package\Tools\Providers\PackageServiceProvider; /** @@ -119,7 +119,7 @@ private function registerApiRoutes(): void Route::group([ 'prefix' => trim($config->string('api.prefix', 'api/ip-intel'), '/') - . '/' . trim($config->string('api.version', 'v1'), '/'), + .'/'.trim($config->string('api.version', 'v1'), '/'), 'middleware' => $middleware, ], function (): void { $this->loadRoutesFrom($this->packagePath('routes/api.php')); diff --git a/src/Rules/ValidIp.php b/src/Rules/ValidIp.php index 897ca9c..20707f9 100644 --- a/src/Rules/ValidIp.php +++ b/src/Rules/ValidIp.php @@ -5,8 +5,8 @@ namespace Simtabi\Laranail\IpIntel\Rules; use Closure; -use Simtabi\Laranail\Atlas\Core\Network\IpAddress; use Illuminate\Contracts\Validation\ValidationRule; +use Simtabi\Laranail\Atlas\Core\Network\IpAddress; /** * A parseable IP address. diff --git a/src/Services/IpIntelManager.php b/src/Services/IpIntelManager.php index 6800609..8eff5db 100644 --- a/src/Services/IpIntelManager.php +++ b/src/Services/IpIntelManager.php @@ -5,19 +5,19 @@ namespace Simtabi\Laranail\IpIntel\Services; use Closure; -use LogicException; -use Illuminate\Http\Request; -use Simtabi\Laranail\IpIntel\Enums\Provider; +use Illuminate\Contracts\Cache\Repository as CacheRepository; use Illuminate\Contracts\Container\Container; -use Simtabi\Laranail\IpIntel\Data\IpIntelResult; -use Simtabi\Laranail\Atlas\Services\AtlasService; +use Illuminate\Http\Request; +use LogicException; use Simtabi\Laranail\Atlas\Core\Network\IpAddress; -use Simtabi\Laranail\IpIntel\Contracts\IntelDriver; -use Simtabi\Laranail\IpIntel\Support\IpIntelConfig; +use Simtabi\Laranail\Atlas\Services\AtlasService; +use Simtabi\Laranail\IpIntel\Adapters\EdgeHeader\EdgeHeaderDriver; use Simtabi\Laranail\IpIntel\Adapters\IpApi\IpApiDriver; use Simtabi\Laranail\IpIntel\Adapters\Local\AtlasDriver; -use Illuminate\Contracts\Cache\Repository as CacheRepository; -use Simtabi\Laranail\IpIntel\Adapters\EdgeHeader\EdgeHeaderDriver; +use Simtabi\Laranail\IpIntel\Contracts\IntelDriver; +use Simtabi\Laranail\IpIntel\Data\IpIntelResult; +use Simtabi\Laranail\IpIntel\Enums\Provider; +use Simtabi\Laranail\IpIntel\Support\IpIntelConfig; /** * The entry point: builds the chain, caches what is worth caching, and hands @@ -44,7 +44,7 @@ public function __construct( ) {} /** - * @param Closure(Container): IntelDriver $factory + * @param Closure(Container): IntelDriver $factory */ public function extend(string $name, Closure $factory): self { @@ -121,8 +121,8 @@ private function lookup(IpAddress|string $address, bool $full): IpIntelResult } $key = $this->config->string('cache.prefix', 'laranail.ip-intel') - . ':' . ($full ? 'full' : 'country') - . ':' . $parsed->address; + .':'.($full ? 'full' : 'country') + .':'.$parsed->address; $cached = $this->cache->get($key); @@ -164,7 +164,7 @@ private function parse(IpAddress|string $address): IpAddress // bad input, and silently continuing with a wrong address would be // worse than saying so. return $parsed ?? throw new LogicException( - 'atlas could not parse ' . self::UNSPECIFIED . ', which every IPv4 parser accepts.', + 'atlas could not parse '.self::UNSPECIFIED.', which every IPv4 parser accepts.', ); } @@ -182,8 +182,8 @@ private function driver(string $name): ?IntelDriver return match ($provider) { Provider::EdgeHeader => $this->container->make(EdgeHeaderDriver::class), - Provider::Local => $this->container->make(AtlasDriver::class), - Provider::IpApi => $this->container->make(IpApiDriver::class), + Provider::Local => $this->container->make(AtlasDriver::class), + Provider::IpApi => $this->container->make(IpApiDriver::class), }; } } diff --git a/src/Services/ResolverChain.php b/src/Services/ResolverChain.php index ea8498e..60e76b8 100644 --- a/src/Services/ResolverChain.php +++ b/src/Services/ResolverChain.php @@ -4,17 +4,17 @@ namespace Simtabi\Laranail\IpIntel\Services; -use Simtabi\Laranail\IpIntel\Data\AsnInfo; -use Simtabi\Laranail\IpIntel\Data\PlaceInfo; -use Simtabi\Laranail\IpIntel\Data\IpIntelResult; -use Simtabi\Laranail\IpIntel\Data\ThreatSignals; -use Simtabi\Laranail\Atlas\Services\AtlasService; use Simtabi\Laranail\Atlas\Core\Network\IpAddress; +use Simtabi\Laranail\Atlas\Services\AtlasService; +use Simtabi\Laranail\IpIntel\Contracts\DetectsThreats; use Simtabi\Laranail\IpIntel\Contracts\IntelDriver; use Simtabi\Laranail\IpIntel\Contracts\ResolvesAsn; use Simtabi\Laranail\IpIntel\Contracts\ResolvesCity; -use Simtabi\Laranail\IpIntel\Contracts\DetectsThreats; use Simtabi\Laranail\IpIntel\Contracts\ResolvesCountry; +use Simtabi\Laranail\IpIntel\Data\AsnInfo; +use Simtabi\Laranail\IpIntel\Data\IpIntelResult; +use Simtabi\Laranail\IpIntel\Data\PlaceInfo; +use Simtabi\Laranail\IpIntel\Data\ThreatSignals; use Simtabi\Laranail\IpIntel\Exceptions\SourceUnavailable; /** @@ -50,7 +50,7 @@ final readonly class ResolverChain { /** - * @param list $drivers in priority order + * @param list $drivers in priority order */ public function __construct( private array $drivers, diff --git a/src/Support/IpIntelConfig.php b/src/Support/IpIntelConfig.php index 3c38fbe..427b420 100644 --- a/src/Support/IpIntelConfig.php +++ b/src/Support/IpIntelConfig.php @@ -46,8 +46,7 @@ public function bool(string $key, bool $default = false): bool } /** - * @param array $default - * + * @param array $default * @return array */ public function array(string $key, array $default = []): array @@ -72,6 +71,6 @@ public function chain(): array private function raw(string $key): mixed { - return $this->config->get(self::PREFIX . '.' . $key); + return $this->config->get(self::PREFIX.'.'.$key); } } diff --git a/tests/Feature/ApiTest.php b/tests/Feature/ApiTest.php index 2db3774..8c45c0d 100644 --- a/tests/Feature/ApiTest.php +++ b/tests/Feature/ApiTest.php @@ -3,10 +3,10 @@ declare(strict_types=1); use Simtabi\Laranail\Atlas\Core\Network\IpAddress; -use Simtabi\Laranail\IpIntel\Services\IpIntelManager; use Simtabi\Laranail\IpIntel\Contracts\ResolvesCountry; use Simtabi\Laranail\IpIntel\Exceptions\SourceUnavailable; use Simtabi\Laranail\IpIntel\Providers\IpIntelServiceProvider; +use Simtabi\Laranail\IpIntel\Services\IpIntelManager; function apiSource(?string $answer = 'KE'): ResolvesCountry { @@ -72,7 +72,7 @@ public function country(IpAddress $address): ?string it('rejects an address that is not one', function (string $ip): void { // A 422 naming the field, not a 500 from somewhere inside a driver. - $this->getJson('api/ip-intel/v1/lookup?ip=' . urlencode($ip)) + $this->getJson('api/ip-intel/v1/lookup?ip='.urlencode($ip)) ->assertStatus(422) ->assertJsonValidationErrorFor('ip'); })->with(['not-an-ip', '01.02.03.04', '256.1.1.1', '']); diff --git a/tests/Feature/ResolverChainTest.php b/tests/Feature/ResolverChainTest.php index b66f690..bafdfd2 100644 --- a/tests/Feature/ResolverChainTest.php +++ b/tests/Feature/ResolverChainTest.php @@ -3,16 +3,16 @@ declare(strict_types=1); use Illuminate\Http\Request; -use Simtabi\Laranail\IpIntel\Data\AsnInfo; -use Simtabi\Laranail\IpIntel\Enums\Outcome; -use Simtabi\Laranail\IpIntel\Facades\IpIntel; -use Simtabi\Laranail\IpIntel\Data\ThreatSignals; use Simtabi\Laranail\Atlas\Core\Network\IpAddress; -use Simtabi\Laranail\IpIntel\Contracts\ResolvesAsn; -use Simtabi\Laranail\IpIntel\Services\IpIntelManager; use Simtabi\Laranail\IpIntel\Contracts\DetectsThreats; +use Simtabi\Laranail\IpIntel\Contracts\ResolvesAsn; use Simtabi\Laranail\IpIntel\Contracts\ResolvesCountry; +use Simtabi\Laranail\IpIntel\Data\AsnInfo; +use Simtabi\Laranail\IpIntel\Data\ThreatSignals; +use Simtabi\Laranail\IpIntel\Enums\Outcome; use Simtabi\Laranail\IpIntel\Exceptions\SourceUnavailable; +use Simtabi\Laranail\IpIntel\Facades\IpIntel; +use Simtabi\Laranail\IpIntel\Services\IpIntelManager; /** * A country-only source that never leaves the machine. @@ -308,7 +308,7 @@ public function country(IpAddress $address): ?string // ----------------------------------------------------------------------- it('reads the country the reverse proxy supplied', function (string $header): void { - $request = Request::create('/', 'GET', server: ['REMOTE_ADDR' => '8.8.8.8', 'HTTP_' . strtoupper(str_replace('-', '_', $header)) => 'KE']); + $request = Request::create('/', 'GET', server: ['REMOTE_ADDR' => '8.8.8.8', 'HTTP_'.strtoupper(str_replace('-', '_', $header)) => 'KE']); app()->instance('request', $request); config()->set('laranail.ip-intel.chain', ['edge']);