smiley 3 лет назад
Родитель
Сommit
92fb9728c8
1 измененных файлов с 5 добавлено и 2 удалено
  1. 5 2
      src/QROptionsTrait.php

+ 5 - 2
src/QROptionsTrait.php

@@ -380,17 +380,20 @@ trait QROptionsTrait{
 	 * sets/clamps the version number
 	 */
 	protected function set_version(int $version):void{
-		$this->version = $version !== Version::AUTO ? max(1, min(40, $version)) : Version::AUTO; // @todo
+		$this->version = $version !== Version::AUTO ? max(1, min(40, $version)) : Version::AUTO;
 	}
 
 	/**
 	 * sets the error correction level
 	 *
+	 * @todo: accept string values (PHP8+)
+	 * @see https://github.com/chillerlan/php-qrcode/discussions/160
+	 *
 	 * @throws \chillerlan\QRCode\QRCodeException
 	 */
 	protected function set_eccLevel(int $eccLevel):void{
 
-		if(!in_array($eccLevel, [EccLevel::L, EccLevel::M, EccLevel::Q, EccLevel::H], true)){
+		if((0b11 & $eccLevel) !== $eccLevel){
 			throw new QRCodeException(sprintf('Invalid error correct level: %s', $eccLevel));
 		}