Skip to content

Commit 6c66d56

Browse files
committed
:octocat: remove QRMatrix::flip()
1 parent 05e99b8 commit 6c66d56

File tree

2 files changed

+7
-34
lines changed

2 files changed

+7
-34
lines changed

src/Data/QRMatrix.php

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -282,18 +282,6 @@ public function setArea(int $startX, int $startY, int $width, int $height, bool
282282
return $this;
283283
}
284284

285-
/**
286-
* Flips the value of the module at ($x, $y)
287-
*/
288-
public function flip(int $x, int $y):self{
289-
290-
if(isset($this->matrix[$y][$x])){
291-
$this->matrix[$y][$x] ^= $this::IS_DARK;
292-
}
293-
294-
return $this;
295-
}
296-
297285
/**
298286
* Checks whether the module at ($x, $y) is of the given $M_TYPE
299287
*
@@ -718,8 +706,13 @@ public function mask(MaskPattern $maskPattern):self{
718706

719707
foreach($this->matrix as $y => $row){
720708
foreach($row as $x => $val){
721-
if($mask($x, $y) && ($val & $this::M_DATA) === $this::M_DATA){
722-
$this->flip($x, $y);
709+
// skip non-data modules
710+
if(($val & $this::M_DATA) !== $this::M_DATA){
711+
continue;
712+
}
713+
714+
if($mask($x, $y)){
715+
$this->set($x, $y, ($val & $this::IS_DARK) !== $this::IS_DARK, $val);
723716
}
724717
}
725718
}

tests/Data/QRMatrixTest.php

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -484,26 +484,6 @@ public function testSetLogoSpaceMaxSizeException():void{
484484
(new QRCode($o))->addByteSegment('testdata')->getQRMatrix()->setLogoSpace(37, 37);
485485
}
486486

487-
/**
488-
* Tests flipping the value of a module
489-
*/
490-
public function testFlip():void{
491-
$this->matrix->set(20, 20, true, QRMatrix::M_TEST);
492-
493-
// cover checkType()
494-
$this::assertTrue($this->matrix->checkType(20, 20, QRMatrix::M_TEST));
495-
// verify the current state (dark)
496-
$this::assertSame(QRMatrix::M_TEST_DARK, $this->matrix->get(20, 20));
497-
// flip
498-
$this->matrix->flip(20, 20);
499-
// verify flip
500-
$this::assertSame(QRMatrix::M_TEST, $this->matrix->get(20, 20));
501-
// flip again
502-
$this->matrix->flip(20, 20);
503-
// verify flip
504-
$this::assertSame(QRMatrix::M_TEST_DARK, $this->matrix->get(20, 20));
505-
}
506-
507487
/**
508488
* Tests checking whether the M_TYPE of a module is not one of an array of M_TYPES
509489
*/

0 commit comments

Comments
 (0)