Skip to content

Commit

Permalink
changed/adapt-qr-for-pix auto-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolass committed May 15, 2024
1 parent b6dccff commit 8171752
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/Qr.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ public function __construct(string $address = '')

public function setAddress(string $address): void
{
$this->address = $address;
$this->address = urldecode($address);
$this->address = str_replace('%2E', '.', $this->address);
$this->address = str_replace('%2D', '-', $this->address);
$this->updateText();
}

Expand Down
7 changes: 4 additions & 3 deletions tests/DefaultQrTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@

/**
* @internal
* @coversNothing
* @covers \CryptoQr\DefaultQr
*/
final class DefaultQrTest extends TestCase
{
public function testQrAddress(): void
{
$qr = new Qr('34ZwZ4cYiwZnYquM4KW67sqT7vY88215CY');
$address = '00020101021226790014br.gov.bcb.pix2557brcode.starkinfra.com/v2/e31f78164ecb4deb9c7efce0bcba7a5b5204000053039865802BR5925Smartpay Servicos Digitai6013Florianopolis62070503***6304CC0F';
$qr = new Qr(urldecode($address));
$pngData = $qr->getQrCode()->writeString();

$reader = new QrReader($pngData, QrReader::SOURCE_TYPE_BLOB);
$this->assertSame('34ZwZ4cYiwZnYquM4KW67sqT7vY88215CY', $reader->text());
$this->assertSame($address, $reader->text());
}
}

0 comments on commit 8171752

Please sign in to comment.