Преглед на файлове

:octocat: remove QRMatrix::flip()

smiley преди 2 години
родител
ревизия
6c66d56a31
променени са 2 файла, в които са добавени 7 реда и са изтрити 34 реда
  1. 7 14
      src/Data/QRMatrix.php
  2. 0 20
      tests/Data/QRMatrixTest.php

+ 7 - 14
src/Data/QRMatrix.php

@@ -282,18 +282,6 @@ class QRMatrix{
 		return $this;
 	}
 
-	/**
-	 * Flips the value of the module at ($x, $y)
-	 */
-	public function flip(int $x, int $y):self{
-
-		if(isset($this->matrix[$y][$x])){
-			$this->matrix[$y][$x] ^= $this::IS_DARK;
-		}
-
-		return $this;
-	}
-
 	/**
 	 * Checks whether the module at ($x, $y) is of the given $M_TYPE
 	 *
@@ -718,8 +706,13 @@ class QRMatrix{
 
 		foreach($this->matrix as $y => $row){
 			foreach($row as $x => $val){
-				if($mask($x, $y) && ($val & $this::M_DATA) === $this::M_DATA){
-					$this->flip($x, $y);
+				// skip non-data modules
+				if(($val & $this::M_DATA) !== $this::M_DATA){
+					continue;
+				}
+
+				if($mask($x, $y)){
+					$this->set($x, $y, ($val & $this::IS_DARK) !== $this::IS_DARK, $val);
 				}
 			}
 		}

+ 0 - 20
tests/Data/QRMatrixTest.php

@@ -484,26 +484,6 @@ final class QRMatrixTest extends TestCase{
 		(new QRCode($o))->addByteSegment('testdata')->getQRMatrix()->setLogoSpace(37, 37);
 	}
 
-	/**
-	 * Tests flipping the value of a module
-	 */
-	public function testFlip():void{
-		$this->matrix->set(20, 20, true, QRMatrix::M_TEST);
-
-		// cover checkType()
-		$this::assertTrue($this->matrix->checkType(20, 20, QRMatrix::M_TEST));
-		// verify the current state (dark)
-		$this::assertSame(QRMatrix::M_TEST_DARK, $this->matrix->get(20, 20));
-		// flip
-		$this->matrix->flip(20, 20);
-		// verify flip
-		$this::assertSame(QRMatrix::M_TEST, $this->matrix->get(20, 20));
-		// flip again
-		$this->matrix->flip(20, 20);
-		// verify flip
-		$this::assertSame(QRMatrix::M_TEST_DARK, $this->matrix->get(20, 20));
-	}
-
 	/**
 	 * Tests checking whether the M_TYPE of a module is not one of an array of M_TYPES
 	 */