Skip to content

Commit

Permalink
Fix error correction level handling
Browse files Browse the repository at this point in the history
  • Loading branch information
endroid committed Dec 1, 2018
1 parent e467439 commit 0095706
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ $qrCode->setSize(300);
$qrCode->setWriterByName('png');
$qrCode->setMargin(10);
$qrCode->setEncoding('UTF-8');
$qrCode->setErrorCorrectionLevel(ErrorCorrectionLevel::HIGH);
$qrCode->setErrorCorrectionLevel(new ErrorCorrectionLevel(ErrorCorrectionLevel::HIGH));
$qrCode->setForegroundColor(['r' => 0, 'g' => 0, 'b' => 0, 'a' => 0]);
$qrCode->setBackgroundColor(['r' => 255, 'g' => 255, 'b' => 255, 'a' => 0]);
$qrCode->setLabel('Scan the code', 16, __DIR__.'/../assets/fonts/noto_sans.otf', LabelAlignment::CENTER);
Expand Down
4 changes: 4 additions & 0 deletions src/Factory/QrCodeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Endroid\QrCode\Factory;

use Endroid\QrCode\ErrorCorrectionLevel;
use Endroid\QrCode\QrCode;
use Endroid\QrCode\QrCodeInterface;
use Endroid\QrCode\WriterRegistryInterface;
Expand Down Expand Up @@ -66,6 +67,9 @@ public function create(string $text = '', array $options = []): QrCodeInterface
$options['writer_by_name'] = $options[$option];
$option = 'writer_by_name';
}
if ('error_correction_level' === $option) {
$options[$option] = new ErrorCorrectionLevel($options[$option]);
}
$accessor->setValue($qrCode, $option, $options[$option]);
}
}
Expand Down

0 comments on commit 0095706

Please sign in to comment.