Sfoglia il codice sorgente

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

codemasher 5 anni fa
parent
commit
96cfff1e9e
4 ha cambiato i file con 9 aggiunte e 6 eliminazioni
  1. 1 1
      src/Data/AlphaNum.php
  2. 1 1
      src/Data/Number.php
  3. 5 2
      src/Data/QRDataInterface.php
  4. 2 2
      src/QRCode.php

+ 1 - 1
src/Data/AlphaNum.php

@@ -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
src/Data/Number.php

@@ -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
src/Data/QRDataInterface.php

@@ -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
src/QRCode.php

@@ -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);
 	}
 
 	/**