Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
PavelJurasek committed Sep 2, 2022
1 parent 01f38f2 commit e45052d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 22 deletions.
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
"type": "library",
"license": "MIT",
"require": {
"php": "^7.1",
"globalcitizen/php-iban": "^2.7",
"endroid/qr-code": "^3.6"
"php": "^8.0",
"globalcitizen/php-iban": "^4.1",
"endroid/qr-code": "^4.5"
},
"require-dev": {
"nette/tester": "^2.0"
"nette/tester": "^2.4"
},
"autoload": {
"psr-4": {
Expand Down
30 changes: 13 additions & 17 deletions src/QRGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@

namespace JedenWeb\QRPayment;

use Endroid\QrCode\ErrorCorrectionLevel;
use Endroid\QrCode\LabelAlignment;
use Endroid\QrCode\QrCode;

/**
* @author Pavel Jurásek
*/
class QRGenerator
{

Expand All @@ -19,16 +12,19 @@ public function create(QRPayment $payment): string

public function createFromString(string $content): string
{
$code = new QrCode($content);
$code->setSize(300);

$code->setWriterByName('png');
$code->setMargin(10);
$code->setEncoding('UTF-8');
$code->setErrorCorrectionLevel(new ErrorCorrectionLevel(ErrorCorrectionLevel::MEDIUM));
$code->setLabel('QR platba', 12, null, LabelAlignment::LEFT);

return $code->writeString();
$builder = \Endroid\QrCode\Builder\Builder::create()
->data($content)
->writer(new \Endroid\QrCode\Writer\PngWriter())
->size(300)
->margin(10)
->encoding(new \Endroid\QrCode\Encoding\Encoding('UTF-8'))
->errorCorrectionLevel(new \Endroid\QrCode\ErrorCorrectionLevel\ErrorCorrectionLevelMedium())
->labelText('QR platba')
->labelFont(new \Endroid\QrCode\Label\Font\OpenSans(12))
->labelAlignment(new \Endroid\QrCode\Label\Alignment\LabelAlignmentLeft())
;

return $builder->build()->getString();
}

}
2 changes: 1 addition & 1 deletion tests/QRGenerator.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class QRGeneratorTest extends Tester\TestCase
$generator = new QRGenerator;

$str = $generator->createFromString('SPD*1.0*ACC:CZ2806000000000168540115*AM:450.00*CC:CZK*MSG:PLATBA ZA ZBOZI*CRC32:e8f0bf9e');
Assert::matchFile(__DIR__ . '/output.png', $str);
Assert::equal(\file_get_contents(__DIR__ . '/output.png'), $str);
}

}
Expand Down
Binary file removed tests/output.png
Binary file not shown.

0 comments on commit e45052d

Please sign in to comment.