Просмотр исходного кода

:octocat: +eec string representation

codemasher 5 лет назад
Родитель
Сommit
eb2ec6f089
1 измененных файлов с 15 добавлено и 1 удалено
  1. 15 1
      src/Common/EccLevel.php

+ 15 - 1
src/Common/EccLevel.php

@@ -37,7 +37,7 @@ final class EccLevel{
 	 *
 	 *
 	 * @see \chillerlan\QRCode\Common\Version::MAX_BITS
 	 * @see \chillerlan\QRCode\Common\Version::MAX_BITS
 	 * @see \chillerlan\QRCode\Common\EccLevel::RSBLOCKS
 	 * @see \chillerlan\QRCode\Common\EccLevel::RSBLOCKS
-	 * @see \chillerlan\QRCode\Data\QRMatrix::formatPattern
+	 * @see \chillerlan\QRCode\Common\EccLevel::formatPattern
 	 *
 	 *
 	 * @var int[]
 	 * @var int[]
 	 */
 	 */
@@ -48,6 +48,13 @@ final class EccLevel{
 		self::H => 3,
 		self::H => 3,
 	];
 	];
 
 
+	public const MODES_STRING = [
+		self::L => 'L',
+		self::M => 'M',
+		self::Q => 'Q',
+		self::H => 'H',
+	];
+
 	/**
 	/**
 	 * ISO/IEC 18004:2000 Tables 13-22
 	 * ISO/IEC 18004:2000 Tables 13-22
 	 *
 	 *
@@ -213,6 +220,13 @@ final class EccLevel{
 		$this->eccLevel = $eccLevel;
 		$this->eccLevel = $eccLevel;
 	}
 	}
 
 
+	/**
+	 * returns the string representation of the current ECC level
+	 */
+	public function __toString():string{
+		return self::MODES_STRING[$this->eccLevel];
+	}
+
 	/**
 	/**
 	 * returns the current ECC level
 	 * returns the current ECC level
 	 */
 	 */