mirror of
https://github.com/chillerlan/php-qrcode.git
synced 2026-08-28 11:07:25 +00:00
:octocat: forgot about these... 💄
This commit is contained in:
+1
-10
@@ -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;
|
||||
|
||||
+1
-3
@@ -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.']');
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
+2
-2
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user