Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/IpDetails.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ private function __construct(
private bool $isEuMember,
private string $stateProv,
private string $city,
private float $latitude,
private float $longitude,
private string $threatLevel,
private bool $isProxy,
private bool $isCrawler,
Expand All @@ -32,6 +34,8 @@ private function __construct(
* ?isEuMember: bool,
* ?stateProv: string,
* ?city: string,
* ?latitude: float,
* ?longitude: float,
* ?threatLevel: string,
* ?isProxy: string,
* ?isCrawler: bool,
Expand All @@ -49,6 +53,8 @@ public static function new(array $data): self
$data['isEuMember'] ?? false,
$data['stateProv'] ?? '',
$data['city'] ?? '',
$data['latitude'] ?? 0.0,
$data['longitude'] ?? 0.0,
$data['threatLevel'] ?? '',
$data['isProxy'] ?? false,
$data['isCrawler'] ?? false,
Expand Down Expand Up @@ -96,6 +102,16 @@ public function getCity(): string
return $this->city;
}

public function getLatitude(): float
{
return $this->latitude;
}

public function getLongitude(): float
{
return $this->longitude;
}

public function getThreatLevel(): string
{
return $this->threatLevel;
Expand Down
4 changes: 4 additions & 0 deletions tests/DbIpClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ public function testFullDetail(): void
self::assertEquals('États-Unis', $ipDetails->getCountryName());
self::assertEquals('Caroline du Sud', $ipDetails->getStateProv());
self::assertEquals('North Charleston', $ipDetails->getCity());

self::assertEquals(32.905, $ipDetails->getLatitude());
self::assertEquals(-79.9611, $ipDetails->getLongitude());

self::assertEquals('low', $ipDetails->getThreatLevel());
self::assertEquals('AT&T Services', $ipDetails->getIsp());
self::assertEquals(false, $ipDetails->isProxy());
Expand Down