Skip to content

Commit cdde12f

Browse files
committed
:octocat: forgot about these... 💄
1 parent 5e31654 commit cdde12f

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

src/Data/AlphaNum.php

+1-10
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,6 @@
1919
*/
2020
class AlphaNum extends QRDataAbstract{
2121

22-
public const CHAR_MAP = [
23-
'0', '1', '2', '3', '4', '5', '6', '7',
24-
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F',
25-
'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
26-
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
27-
'W', 'X', 'Y', 'Z', ' ', '$', '%', '*',
28-
'+', '-', '.', '/', ':',
29-
];
30-
3122
/**
3223
* @inheritdoc
3324
*/
@@ -60,7 +51,7 @@ protected function write(string $data):void{
6051
* @throws \chillerlan\QRCode\Data\QRCodeDataException
6152
*/
6253
protected function getCharCode(string $chr):int{
63-
$i = array_search($chr, $this::CHAR_MAP);
54+
$i = array_search($chr, $this::ALPHANUM_CHAR_MAP);
6455

6556
if($i !== false){
6657
return $i;

src/Data/Number.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
*/
2020
class Number extends QRDataAbstract{
2121

22-
public const CHAR_MAP = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
23-
2422
/**
2523
* @inheritdoc
2624
*/
@@ -70,7 +68,7 @@ protected function parseInt(string $string):int{
7068
for($i = 0; $i < $len; $i++){
7169
$c = ord($string[$i]);
7270

73-
if(!in_array($string[$i], $this::CHAR_MAP, true)){
71+
if(!in_array($string[$i], $this::NUMBER_CHAR_MAP, true)){
7472
throw new QRCodeDataException('illegal char: "'.$string[$i].'" ['.$c.']');
7573
}
7674

src/Data/QRDataInterface.php

+11
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,17 @@
1717
*/
1818
interface QRDataInterface{
1919

20+
const NUMBER_CHAR_MAP = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
21+
22+
const ALPHANUM_CHAR_MAP = [
23+
'0', '1', '2', '3', '4', '5', '6', '7',
24+
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F',
25+
'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
26+
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
27+
'W', 'X', 'Y', 'Z', ' ', '$', '%', '*',
28+
'+', '-', '.', '/', ':',
29+
];
30+
2031
/**
2132
* @link http://www.qrcode.com/en/about/version.html
2233
*/

src/QRCode.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ protected function initOutputInterface(string $data):QROutputInterface{
230230
* @return bool
231231
*/
232232
public function isNumber(string $string):bool{
233-
return $this->checkString($string, Number::CHAR_MAP);
233+
return $this->checkString($string, QRDataInterface::NUMBER_CHAR_MAP);
234234
}
235235

236236
/**
@@ -241,7 +241,7 @@ public function isNumber(string $string):bool{
241241
* @return bool
242242
*/
243243
public function isAlphaNum(string $string):bool{
244-
return $this->checkString($string, AlphaNum::CHAR_MAP);
244+
return $this->checkString($string, QRDataInterface::ALPHANUM_CHAR_MAP);
245245
}
246246

247247
/**

0 commit comments

Comments
 (0)