From 4d15315e070f6e1907890f46e72e9d3ee238bb57 Mon Sep 17 00:00:00 2001 From: Thomas P Date: Mon, 4 Oct 2021 22:12:15 +0200 Subject: [PATCH] Add StateProvCode property --- src/IpDetails.php | 12 ++++++++++-- tests/DbIpClientTest.php | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/IpDetails.php b/src/IpDetails.php index 279e0a6..11b001f 100644 --- a/src/IpDetails.php +++ b/src/IpDetails.php @@ -12,6 +12,7 @@ private function __construct( private string $continentName, private string $countryCode, private string $countryName, + private string $stateProvCode, private bool $isEuMember, private string $stateProv, private string $city, @@ -29,6 +30,7 @@ private function __construct( * ?continentName: string, * ?countryCode: string, * ?countryName: string, + * ?stateProvCode: string, * ?isEuMember: bool, * ?stateProv: string, * ?city: string, @@ -46,6 +48,7 @@ public static function new(array $data): self $data['continentName'] ?? '', $data['countryCode'] ?? '', $data['countryName'] ?? '', + $data['stateProvCode'] ?? '', $data['isEuMember'] ?? false, $data['stateProv'] ?? '', $data['city'] ?? '', @@ -81,9 +84,9 @@ public function getCountryName(): string return $this->countryName; } - public function isEuMember(): bool + public function getStateProvCode(): string { - return $this->isEuMember; + return $this->stateProvCode; } public function getStateProv(): string @@ -91,6 +94,11 @@ public function getStateProv(): string return $this->stateProv; } + public function isEuMember(): bool + { + return $this->isEuMember; + } + public function getCity(): string { return $this->city; diff --git a/tests/DbIpClientTest.php b/tests/DbIpClientTest.php index 2536203..dd30498 100644 --- a/tests/DbIpClientTest.php +++ b/tests/DbIpClientTest.php @@ -56,6 +56,7 @@ public function testFullDetail(): void self::assertEquals('US', $ipDetails->getCountryCode()); self::assertEquals('États-Unis', $ipDetails->getCountryName()); self::assertEquals('Caroline du Sud', $ipDetails->getStateProv()); + self::assertEquals('SC', $ipDetails->getStateProvCode()); self::assertEquals('North Charleston', $ipDetails->getCity()); self::assertEquals('low', $ipDetails->getThreatLevel()); self::assertEquals('AT&T Services', $ipDetails->getIsp());