summaryrefslogtreecommitdiff
path: root/vendor/chillerlan/php-qrcode/src/Data/AlphaNum.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/chillerlan/php-qrcode/src/Data/AlphaNum.php')
-rw-r--r--vendor/chillerlan/php-qrcode/src/Data/AlphaNum.php29
1 files changed, 12 insertions, 17 deletions
diff --git a/vendor/chillerlan/php-qrcode/src/Data/AlphaNum.php b/vendor/chillerlan/php-qrcode/src/Data/AlphaNum.php
index c6d34e76f..28d9d7563 100644
--- a/vendor/chillerlan/php-qrcode/src/Data/AlphaNum.php
+++ b/vendor/chillerlan/php-qrcode/src/Data/AlphaNum.php
@@ -14,22 +14,19 @@ namespace chillerlan\QRCode\Data;
use chillerlan\QRCode\QRCode;
-use function array_search, ord, sprintf;
+use function ord, sprintf;
/**
* Alphanumeric mode: 0 to 9, A to Z, space, $ % * + - . / :
+ *
+ * ISO/IEC 18004:2000 Section 8.3.3
+ * ISO/IEC 18004:2000 Section 8.4.3
*/
-class AlphaNum extends QRDataAbstract{
+final class AlphaNum extends QRDataAbstract{
- /**
- * @inheritdoc
- */
- protected $datamode = QRCode::DATA_ALPHANUM;
+ protected int $datamode = QRCode::DATA_ALPHANUM;
- /**
- * @inheritdoc
- */
- protected $lengthBits = [9, 11, 13];
+ protected array $lengthBits = [9, 11, 13];
/**
* @inheritdoc
@@ -47,19 +44,17 @@ class AlphaNum extends QRDataAbstract{
}
/**
- * @param string $chr
+ * get the code for the given character
*
- * @return int
- * @throws \chillerlan\QRCode\Data\QRCodeDataException
+ * @throws \chillerlan\QRCode\Data\QRCodeDataException on an illegal character occurence
*/
protected function getCharCode(string $chr):int{
- $i = array_search($chr, $this::ALPHANUM_CHAR_MAP);
- if($i !== false){
- return $i;
+ if(!isset($this::CHAR_MAP_ALPHANUM[$chr])){
+ throw new QRCodeDataException(sprintf('illegal char: "%s" [%d]', $chr, ord($chr)));
}
- throw new QRCodeDataException(sprintf('illegal char: "%s" [%d]', $chr, ord($chr)));
+ return $this::CHAR_MAP_ALPHANUM[$chr];
}
}