From af201763b6e975fe96d95236d0521b75d8599be2 Mon Sep 17 00:00:00 2001 From: codemasher Date: Sun, 5 Apr 2020 03:24:35 +0200 Subject: [PATCH] :shower: clean up QRCode::checkString() --- src/QRCode.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/QRCode.php b/src/QRCode.php index 4fc5160ef..f83bcc39e 100755 --- a/src/QRCode.php +++ b/src/QRCode.php @@ -20,7 +20,7 @@ use chillerlan\QRCode\Output\{ }; use chillerlan\Settings\SettingsContainerInterface; -use function call_user_func_array, class_exists, in_array, mb_internal_encoding, ord, strlen, strtolower; +use function call_user_func_array, class_exists, in_array, mb_internal_encoding, ord, strlen, strtolower, str_split; /** * Turns a text string into a Model 2 QR Code @@ -288,10 +288,9 @@ class QRCode{ * checks is a given $string matches the characters of a given $charmap, returns false on the first invalid occurence. */ protected function checkString(string $string, array $charmap):bool{ - $len = strlen($string); - for($i = 0; $i < $len; $i++){ - if(!isset($charmap[$string[$i]])){ + foreach(str_split($string) as $chr){ + if(!isset($charmap[$chr])){ return false; } }