Skip to content

Commit a2e8437

Browse files
Change Issuer code type from int to string (#195)
* Change Issuer code type from int to string * Change type from int to string on issuer code class property * Add change to changelog * Change changelog text
1 parent d568af8 commit a2e8437

File tree

5 files changed

+16
-14
lines changed

5 files changed

+16
-14
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
### Fixed
9+
- Fix bug where issuers wouldn't be able to load because of wrong issuer code type (int instead of string)
810

911
## [3.0.1] - 2020-09-02
1012
### Fixed

src/Api/Issuers/Issuer.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Issuer
2020
private $gatewayCode;
2121

2222
/**
23-
* @var int
23+
* @var string
2424
*/
2525
private $code;
2626

@@ -37,10 +37,10 @@ class Issuer
3737
/**
3838
* Issuer constructor.
3939
* @param string $gatewayCode
40-
* @param int $code
40+
* @param string $code
4141
* @param string $description
4242
*/
43-
public function __construct(string $gatewayCode, int $code, string $description)
43+
public function __construct(string $gatewayCode, string $code, string $description)
4444
{
4545
$this->validateGatewayCode($gatewayCode);
4646
$this->gatewayCode = strtoupper($gatewayCode);
@@ -71,9 +71,9 @@ public function getGatewayCode(): string
7171
}
7272

7373
/**
74-
* @return int
74+
* @return string
7575
*/
76-
public function getCode(): int
76+
public function getCode(): string
7777
{
7878
return $this->code;
7979
}

src/Api/Issuers/IssuerListing.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class IssuerListing
2222
public function __construct(string $gatewayCode, array $data)
2323
{
2424
foreach ($data as $issuerData) {
25-
$this->issuers[] = new Issuer($gatewayCode, (int)$issuerData['code'], $issuerData['description']);
25+
$this->issuers[] = new Issuer($gatewayCode, $issuerData['code'], $issuerData['description']);
2626
}
2727
}
2828

tests/Unit/Api/Issuers/IssuerListingTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ class IssuerListingTest extends TestCase
1616
*/
1717
public function testGetIssuers()
1818
{
19-
$issuerListing = new IssuerListing('ideal', [['code' => 1234, 'description' => 'bar']]);
19+
$issuerListing = new IssuerListing('ideal', [['code' => '0021', 'description' => 'bar']]);
2020
$issuers = $issuerListing->getIssuers();
21-
$this->assertEquals(1, count($issuers));
21+
$this->assertCount(1, $issuers);
2222

2323
$issuer = array_shift($issuers);
24-
$this->assertEquals(1234, $issuer->getCode());
24+
$this->assertEquals('0021', $issuer->getCode());
2525
$this->assertEquals('bar', $issuer->getDescription());
2626
}
2727
}

tests/Unit/Api/Issuers/IssuerTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,21 @@ class IssuerTest extends TestCase
1717
*/
1818
public function testNormalInitialization()
1919
{
20-
$issuer = new Issuer('ideal', 1234, 'bar');
20+
$issuer = new Issuer('ideal', '0021', 'bar');
2121
$this->assertEquals('IDEAL', $issuer->getGatewayCode());
22-
$this->assertEquals(1234, $issuer->getCode());
22+
$this->assertEquals('0021', $issuer->getCode());
2323
$this->assertEquals('bar', $issuer->getDescription());
2424

25-
$issuer = new Issuer('IDEAL', 1234, 'bar');
25+
$issuer = new Issuer('IDEAL', '0021', 'bar');
2626
$this->assertEquals('IDEAL', $issuer->getGatewayCode());
2727
}
2828

2929
/**
3030
* Test if initialization fails if invalid gateway code is used
3131
*/
32-
public function testInitializationWithWrongGatewayCode()
32+
public function testInitializationWithInvalidGatewayCode()
3333
{
3434
$this->expectException(InvalidArgumentException::class);
35-
new Issuer('wrong', 1234, 'foobar');
35+
new Issuer('wrong', '0021', 'foobar');
3636
}
3737
}

0 commit comments

Comments
 (0)