Skip to content

Commit 4c5891c

Browse files
committed
fix HLR lookup gsm_code type mismatch
Changes: - Change LookupHlr::$gsmCode type from ?string to ?int - Update tests to expect integer instead of string - Fix README HLR example to use correct method names The API now consistently returns gsm_code as integer (previously string), causing TypeError in strict_types mode. This aligns with GSM error code standard which uses numeric values (0 = no error, 1-255 = error codes).
1 parent 1b2cc6f commit 4c5891c

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,13 @@ $response = $smsResource->dispatch($params);
117117
use Seven\Api\Resource\Lookup\LookupResource;
118118

119119
$lookupResource = new LookupResource($client);
120-
$result = $lookupResource->hlr('+491234567890');
120+
$results = $lookupResource->hlr('+491234567890');
121+
$hlr = $results[0];
121122

122-
echo "Carrier: " . $result->getCarrier();
123-
echo "Country: " . $result->getCountry();
123+
echo "Current Carrier: " . $hlr->getCurrentCarrier()->getName() . "\n";
124+
echo "Country: " . $hlr->getCountryName() . "\n";
125+
echo "Reachable: " . $hlr->getReachable() . "\n";
126+
echo "Ported: " . $hlr->getPorted() . "\n";
124127
```
125128

126129
### Check account balance

src/Resource/Lookup/LookupHlr.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class LookupHlr {
77
protected ?string $countryName;
88
protected string|false $countryPrefix;
99
protected Carrier $currentCarrier;
10-
protected ?string $gsmCode;
10+
protected ?int $gsmCode;
1111
protected ?string $gsmMessage;
1212
protected string $internationalFormatNumber;
1313
protected string $internationalFormatted;
@@ -59,7 +59,7 @@ public function getCurrentCarrier(): Carrier {
5959
return $this->currentCarrier;
6060
}
6161

62-
public function getGsmCode(): ?string {
62+
public function getGsmCode(): ?int {
6363
return $this->gsmCode;
6464
}
6565

tests/LookupTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function testHlr(): void {
6868
$this->assertNotEmpty($hlr->getCountryName());
6969
$this->assertNotEmpty($hlr->getCountryPrefix());
7070
$this->assertCarrier($hlr->getCurrentCarrier());
71-
$this->assertIsString($hlr->getGsmCode());
71+
$this->assertIsInt($hlr->getGsmCode());
7272
$this->assertNotEmpty($hlr->getGsmMessage());
7373
$this->assertNotEmpty($hlr->getInternationalFormatNumber());
7474
$this->assertNotEmpty($hlr->getInternationalFormatted());
@@ -107,7 +107,7 @@ public function testHlrFaulty(): void {
107107
$this->assertNull($hlr->getCountryName());
108108
$this->assertFalse($hlr->getCountryPrefix());
109109
$this->assertCarrier($hlr->getCurrentCarrier(), true);
110-
$this->assertTrue($hlr->getGsmCode() === null || $hlr->getGsmCode() === '0');
110+
$this->assertTrue($hlr->getGsmCode() === null || $hlr->getGsmCode() === 0);
111111
$this->assertTrue($hlr->getGsmMessage() === null || is_string($hlr->getGsmMessage()));
112112
$this->assertEmpty($hlr->getInternationalFormatNumber());
113113
$this->assertEmpty($hlr->getInternationalFormatted());

0 commit comments

Comments
 (0)