Skip to content

Commit

Permalink
Adjust QrPaymentReferenceGenerator to match RfCreditorReferenceGenera…
Browse files Browse the repository at this point in the history
…tor structure
  • Loading branch information
sprain committed Aug 3, 2020
1 parent 9ed55be commit e503ad1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
15 changes: 9 additions & 6 deletions src/Reference/QrPaymentReferenceGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,17 @@ class QrPaymentReferenceGenerator implements SelfValidatableInterface

public static function generate(?string $customerIdentificationNumber, string $referenceNumber): string
{
$qrPaymentReferenceGenerator = new self();
$qrPaymentReferenceGenerator = new self($customerIdentificationNumber, $referenceNumber);

return $qrPaymentReferenceGenerator->doGenerate();
}

public function __construct(?string $customerIdentificationNumber, string $referenceNumber)
{
if (null !== $customerIdentificationNumber) {
$qrPaymentReferenceGenerator->customerIdentificationNumber = StringModifier::stripWhitespace($customerIdentificationNumber);
$this->customerIdentificationNumber = StringModifier::stripWhitespace($customerIdentificationNumber);
}
$qrPaymentReferenceGenerator->referenceNumber = StringModifier::stripWhitespace($referenceNumber);

return $qrPaymentReferenceGenerator->doGenerate();
$this->referenceNumber = StringModifier::stripWhitespace($referenceNumber);
}

public function getCustomerIdentificationNumber(): ?string
Expand All @@ -42,7 +45,7 @@ public function getReferenceNumber(): ?string
return $this->referenceNumber;
}

private function doGenerate(): string
public function doGenerate(): string
{
if (!$this->isValid()) {
throw new InvalidQrPaymentReferenceException(
Expand Down
15 changes: 14 additions & 1 deletion tests/Reference/QrPaymentReferenceGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,20 @@ public function setUp()
/**
* @dataProvider qrPaymentReferenceProvider
*/
public function testQrPaymentReference($customerIdentification, $referenceNumber, $expectedResult)
public function testMakesResultsViaConstructor($customerIdentification, $referenceNumber, $expectedResult)
{
$qrReference = new QrPaymentReferenceGenerator(
$customerIdentification,
$referenceNumber
);

$this->assertSame($expectedResult, $qrReference->doGenerate());
}

/**
* @dataProvider qrPaymentReferenceProvider
*/
public function testMakesResultsViaFacade($customerIdentification, $referenceNumber, $expectedResult)
{
$qrReference = QrPaymentReferenceGenerator::generate(
$customerIdentification,
Expand Down

0 comments on commit e503ad1

Please sign in to comment.