From cdde12f89c46594dc1972db87d93450ac397cb29 Mon Sep 17 00:00:00 2001 From: codemasher Date: Mon, 1 Oct 2018 13:36:56 +0200 Subject: [PATCH] :octocat: forgot about these... :lipstick: --- src/Data/AlphaNum.php | 11 +---------- src/Data/Number.php | 4 +--- src/Data/QRDataInterface.php | 11 +++++++++++ src/QRCode.php | 4 ++-- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Data/AlphaNum.php b/src/Data/AlphaNum.php index f8436e158..1bf8978ea 100644 --- a/src/Data/AlphaNum.php +++ b/src/Data/AlphaNum.php @@ -19,15 +19,6 @@ use chillerlan\QRCode\QRCode; */ class AlphaNum extends QRDataAbstract{ - public const CHAR_MAP = [ - '0', '1', '2', '3', '4', '5', '6', '7', - '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', - 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', - 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', - 'W', 'X', 'Y', 'Z', ' ', '$', '%', '*', - '+', '-', '.', '/', ':', - ]; - /** * @inheritdoc */ @@ -60,7 +51,7 @@ class AlphaNum extends QRDataAbstract{ * @throws \chillerlan\QRCode\Data\QRCodeDataException */ protected function getCharCode(string $chr):int{ - $i = array_search($chr, $this::CHAR_MAP); + $i = array_search($chr, $this::ALPHANUM_CHAR_MAP); if($i !== false){ return $i; diff --git a/src/Data/Number.php b/src/Data/Number.php index f65d8c92b..cb9e47193 100644 --- a/src/Data/Number.php +++ b/src/Data/Number.php @@ -19,8 +19,6 @@ use chillerlan\QRCode\QRCode; */ class Number extends QRDataAbstract{ - public const CHAR_MAP = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']; - /** * @inheritdoc */ @@ -70,7 +68,7 @@ class Number extends QRDataAbstract{ for($i = 0; $i < $len; $i++){ $c = ord($string[$i]); - if(!in_array($string[$i], $this::CHAR_MAP, true)){ + if(!in_array($string[$i], $this::NUMBER_CHAR_MAP, true)){ throw new QRCodeDataException('illegal char: "'.$string[$i].'" ['.$c.']'); } diff --git a/src/Data/QRDataInterface.php b/src/Data/QRDataInterface.php index d0c9bdea3..a558ab9fd 100644 --- a/src/Data/QRDataInterface.php +++ b/src/Data/QRDataInterface.php @@ -17,6 +17,17 @@ namespace chillerlan\QRCode\Data; */ interface QRDataInterface{ + const NUMBER_CHAR_MAP = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']; + + const ALPHANUM_CHAR_MAP = [ + '0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', + 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', + 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', + 'W', 'X', 'Y', 'Z', ' ', '$', '%', '*', + '+', '-', '.', '/', ':', + ]; + /** * @link http://www.qrcode.com/en/about/version.html */ diff --git a/src/QRCode.php b/src/QRCode.php index e4cd3c14c..647cc0246 100755 --- a/src/QRCode.php +++ b/src/QRCode.php @@ -230,7 +230,7 @@ class QRCode{ * @return bool */ public function isNumber(string $string):bool{ - return $this->checkString($string, Number::CHAR_MAP); + return $this->checkString($string, QRDataInterface::NUMBER_CHAR_MAP); } /** @@ -241,7 +241,7 @@ class QRCode{ * @return bool */ public function isAlphaNum(string $string):bool{ - return $this->checkString($string, AlphaNum::CHAR_MAP); + return $this->checkString($string, QRDataInterface::ALPHANUM_CHAR_MAP); } /**