From 60735bafc215511d950189ebec2699ebe5a806b0 Mon Sep 17 00:00:00 2001 From: smiley Date: Tue, 12 Jul 2022 19:23:20 +0200 Subject: [PATCH] :shower: --- src/Common/BitBuffer.php | 2 +- src/Data/QRData.php | 5 ++--- src/QROptionsTrait.php | 22 +++++++++++----------- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/Common/BitBuffer.php b/src/Common/BitBuffer.php index 8c6682803..26d5c69bb 100644 --- a/src/Common/BitBuffer.php +++ b/src/Common/BitBuffer.php @@ -128,7 +128,7 @@ final class BitBuffer{ $numBits -= $toRead; $this->bitsRead += $toRead; - if($this->bitsRead == 8){ + if($this->bitsRead === 8){ $this->bitsRead = 0; $this->bytesRead++; } diff --git a/src/Data/QRData.php b/src/Data/QRData.php index dc9e88a47..594dffb86 100644 --- a/src/Data/QRData.php +++ b/src/Data/QRData.php @@ -14,7 +14,7 @@ use chillerlan\QRCode\Common\{BitBuffer, EccLevel, MaskPattern, Mode, Version}; use chillerlan\QRCode\QRCode; use chillerlan\Settings\SettingsContainerInterface; -use function range, sprintf; +use function sprintf; /** * Processes the binary data and maps it on a matrix which is then being returned @@ -144,8 +144,7 @@ final class QRData{ $total = $this->estimateTotalBitLength(); // guess the version number within the given range - foreach(range($this->options->versionMin, $this->options->versionMax) as $version){ - + for($version = $this->options->versionMin; $version <= $this->options->versionMax; $version++){ if($total <= $this->maxBitsForEcc[$version]){ return $version; } diff --git a/src/QROptionsTrait.php b/src/QROptionsTrait.php index 4c167fab7..e78e4756a 100644 --- a/src/QROptionsTrait.php +++ b/src/QROptionsTrait.php @@ -363,6 +363,17 @@ trait QROptionsTrait{ $this->setMinMaxVersion($this->versionMin, $version); } + /** + * sets/clamps the version number + */ + protected function set_version(int $version):void{ + + if($version !== QRCode::VERSION_AUTO){ + $this->version = max(1, min(40, $version)); + } + + } + /** * sets the error correction level * @@ -428,17 +439,6 @@ trait QROptionsTrait{ $this->imageTransparencyBG = array_values($this->imageTransparencyBG); } - /** - * sets/clamps the version number - */ - protected function set_version(int $version):void{ - - if($version !== QRCode::VERSION_AUTO){ - $this->version = max(1, min(40, $version)); - } - - } - /** * sets the FPDF measurement unit *