فهرست منبع

:octocat: QROptionsTrait: remove unnecessary set_eccLevel() and set_maskPattern()

smiley 2 سال پیش
والد
کامیت
29e8812b77
2فایلهای تغییر یافته به همراه0 افزوده شده و 60 حذف شده
  1. 0 28
      src/QROptionsTrait.php
  2. 0 32
      tests/QROptionsTest.php

+ 0 - 28
src/QROptionsTrait.php

@@ -389,34 +389,6 @@ trait QROptionsTrait{
 		$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((0b11 & $eccLevel) !== $eccLevel){
-			throw new QRCodeException(sprintf('Invalid error correct level: %s', $eccLevel));
-		}
-
-		$this->eccLevel = $eccLevel;
-	}
-
-	/**
-	 * sets/clamps the mask pattern
-	 */
-	protected function set_maskPattern(int $maskPattern):void{
-
-		if($maskPattern !== MaskPattern::AUTO){
-			$this->maskPattern = max(0, min(7, $maskPattern));
-		}
-
-	}
-
 	/**
 	 * sets/clamps the quiet zone size
 	 */

+ 0 - 32
tests/QROptionsTest.php

@@ -68,38 +68,6 @@ final class QROptionsTest extends TestCase{
 		$this::assertSame($expectedMax, $o->versionMax);
 	}
 
-	/**
-	 * @return int[][]
-	 */
-	public function MaskPatternProvider():array{
-		return [
-			'exceed max'   => [42, 7,],
-			'exceed min'   => [-42, 0],
-			'default (-1)' => [MaskPattern::AUTO, -1],
-		];
-	}
-
-	/**
-	 * Tests the $maskPattern clamping
-	 *
-	 * @dataProvider MaskPatternProvider
-	 */
-	public function testMaskPatternClamp(int $maskPattern, int $expected):void{
-		$o = new QROptions(['maskPattern' => $maskPattern]);
-
-		$this::assertSame($expected, $o->maskPattern);
-	}
-
-	/**
-	 * Tests if an exception is thrown on an incorrect ECC level
-	 */
-	public function testInvalidEccLevelException():void{
-		$this->expectException(QRCodeException::class);
-		$this->expectExceptionMessage('Invalid error correct level: 42');
-
-		$o = new QROptions(['eccLevel' => 42]);
-	}
-
 	/**
 	 * @return int[][][]
 	 */