🚿 consistency: renamed constants QRDataInterface::*_CHAR_MAP -> CHAR_MAP_*

This commit is contained in:
codemasher
2020-03-31 01:29:08 +02:00
parent 5c1a27ba60
commit 96cfff1e9e
4 changed files with 9 additions and 6 deletions
+1 -1
View File
@@ -44,7 +44,7 @@ class AlphaNum extends QRDataAbstract{
* @throws \chillerlan\QRCode\Data\QRCodeDataException
*/
protected function getCharCode(string $chr):int{
$i = array_search($chr, $this::ALPHANUM_CHAR_MAP);
$i = array_search($chr, $this::CHAR_MAP_ALPHANUM);
if($i !== false){
return $i;
+1 -1
View File
@@ -59,7 +59,7 @@ class Number extends QRDataAbstract{
for($i = 0; $i < $len; $i++){
$c = ord($string[$i]);
if(!in_array($string[$i], $this::NUMBER_CHAR_MAP, true)){
if(!in_array($string[$i], $this::CHAR_MAP_NUMBER, true)){
throw new QRCodeDataException(sprintf('illegal char: "%s" [%d]', $string[$i], $c));
}
+5 -2
View File
@@ -17,9 +17,12 @@ namespace chillerlan\QRCode\Data;
*/
interface QRDataInterface{
const NUMBER_CHAR_MAP = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
const CHAR_MAP_NUMBER = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
const ALPHANUM_CHAR_MAP = [
/**
* ISO/IEC 18004:2000 Table 5
*/
const CHAR_MAP_ALPHANUM = [
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F',
'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
+2 -2
View File
@@ -229,14 +229,14 @@ class QRCode{
* checks if a string qualifies as numeric
*/
public function isNumber(string $string):bool{
return $this->checkString($string, QRDataInterface::NUMBER_CHAR_MAP);
return $this->checkString($string, QRDataInterface::CHAR_MAP_NUMBER);
}
/**
* checks if a string qualifies as alphanumeric
*/
public function isAlphaNum(string $string):bool{
return $this->checkString($string, QRDataInterface::ALPHANUM_CHAR_MAP);
return $this->checkString($string, QRDataInterface::CHAR_MAP_ALPHANUM);
}
/**