Skip to content

Commit 0095706

Browse files
committed
Fix error correction level handling
1 parent e467439 commit 0095706

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ $qrCode->setSize(300);
4848
$qrCode->setWriterByName('png');
4949
$qrCode->setMargin(10);
5050
$qrCode->setEncoding('UTF-8');
51-
$qrCode->setErrorCorrectionLevel(ErrorCorrectionLevel::HIGH);
51+
$qrCode->setErrorCorrectionLevel(new ErrorCorrectionLevel(ErrorCorrectionLevel::HIGH));
5252
$qrCode->setForegroundColor(['r' => 0, 'g' => 0, 'b' => 0, 'a' => 0]);
5353
$qrCode->setBackgroundColor(['r' => 255, 'g' => 255, 'b' => 255, 'a' => 0]);
5454
$qrCode->setLabel('Scan the code', 16, __DIR__.'/../assets/fonts/noto_sans.otf', LabelAlignment::CENTER);

src/Factory/QrCodeFactory.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Endroid\QrCode\Factory;
1313

14+
use Endroid\QrCode\ErrorCorrectionLevel;
1415
use Endroid\QrCode\QrCode;
1516
use Endroid\QrCode\QrCodeInterface;
1617
use Endroid\QrCode\WriterRegistryInterface;
@@ -66,6 +67,9 @@ public function create(string $text = '', array $options = []): QrCodeInterface
6667
$options['writer_by_name'] = $options[$option];
6768
$option = 'writer_by_name';
6869
}
70+
if ('error_correction_level' === $option) {
71+
$options[$option] = new ErrorCorrectionLevel($options[$option]);
72+
}
6973
$accessor->setValue($qrCode, $option, $options[$option]);
7074
}
7175
}

0 commit comments

Comments
 (0)