From 61128e4aec576087a4e122c771972a28beba3b0e Mon Sep 17 00:00:00 2001 From: smiley Date: Thu, 9 Mar 2023 19:08:37 +0100 Subject: [PATCH] :sparkles: change QRMatrix::checkTypeNotIn() to checkTypeIn() --- examples/svgMeltedModules.php | 2 +- examples/svgRandomColoredDots.php | 2 +- examples/svgRoundQuietzone.php | 2 +- src/Data/QRMatrix.php | 10 +++++----- src/Output/QRGdImage.php | 2 +- src/Output/QRImagick.php | 2 +- src/Output/QRMarkupSVG.php | 2 +- src/Output/QROutputAbstract.php | 2 +- tests/Data/QRMatrixTest.php | 10 +++++----- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/examples/svgMeltedModules.php b/examples/svgMeltedModules.php index 2c0a7c131..4650bee40 100644 --- a/examples/svgMeltedModules.php +++ b/examples/svgMeltedModules.php @@ -42,7 +42,7 @@ class MeltedSVGQRCodeOutput extends QRMarkupSVG{ foreach($row as $x => $M_TYPE){ $M_TYPE_LAYER = $M_TYPE; - if($this->options->connectPaths && $this->matrix->checkTypeNotIn($x, $y, $this->options->excludeFromConnect)){ + if($this->options->connectPaths && !$this->matrix->checkTypeIn($x, $y, $this->options->excludeFromConnect)){ // to connect paths we'll redeclare the $M_TYPE_LAYER to data only $M_TYPE_LAYER = QRMatrix::M_DATA; diff --git a/examples/svgRandomColoredDots.php b/examples/svgRandomColoredDots.php index 00fa21bfe..04f803beb 100644 --- a/examples/svgRandomColoredDots.php +++ b/examples/svgRandomColoredDots.php @@ -46,7 +46,7 @@ class RandomDotsSVGOutput extends QRMarkupSVG{ $M_TYPE_LAYER = $M_TYPE; if($this->options->connectPaths - && $this->matrix->checkTypeNotIn($x, $y, $this->options->excludeFromConnect) + && !$this->matrix->checkTypeIn($x, $y, $this->options->excludeFromConnect) ){ // to connect paths we'll redeclare the $M_TYPE_LAYER to data only $M_TYPE_LAYER = QRMatrix::M_DATA; diff --git a/examples/svgRoundQuietzone.php b/examples/svgRoundQuietzone.php index 8d534c1b3..93664ca93 100644 --- a/examples/svgRoundQuietzone.php +++ b/examples/svgRoundQuietzone.php @@ -179,7 +179,7 @@ class RoundQuietzoneSVGoutput extends QRMarkupSVG{ foreach($row as $x => $M_TYPE){ $M_TYPE_LAYER = $M_TYPE; - if($this->matrix->checkTypeNotIn($x, $y, $this->options->excludeFromConnect)){ + if(!$this->matrix->checkTypeIn($x, $y, $this->options->excludeFromConnect)){ // to connect paths we'll redeclare the $M_TYPE_LAYER to data only $M_TYPE_LAYER = QRMatrix::M_DATA; diff --git a/src/Data/QRMatrix.php b/src/Data/QRMatrix.php index eaf255afe..236fb23b1 100755 --- a/src/Data/QRMatrix.php +++ b/src/Data/QRMatrix.php @@ -236,18 +236,18 @@ class QRMatrix{ } /** - * checks whether the module at ($x, $y) is not in the given array of $M_TYPES, - * returns true if no matches are found, otherwise false. + * checks whether the module at ($x, $y) is in the given array of $M_TYPES, + * returns true if a match is found, otherwise false. */ - public function checkTypeNotIn(int $x, int $y, array $M_TYPES):bool{ + public function checkTypeIn(int $x, int $y, array $M_TYPES):bool{ foreach($M_TYPES as $type){ if($this->checkType($x, $y, $type)){ - return false; + return true; } } - return true; + return false; } /** diff --git a/src/Output/QRGdImage.php b/src/Output/QRGdImage.php index 08b522a68..6fd7454ac 100644 --- a/src/Output/QRGdImage.php +++ b/src/Output/QRGdImage.php @@ -172,7 +172,7 @@ class QRGdImage extends QROutputAbstract{ /** @phan-suppress-next-line PhanParamTooFewInternalUnpack */ $color = imagecolorallocate($this->image, ...$this->moduleValues[$M_TYPE]); - $this->options->drawCircularModules && $this->matrix->checkTypeNotIn($x, $y, $this->options->keepAsSquare) + $this->options->drawCircularModules && !$this->matrix->checkTypeIn($x, $y, $this->options->keepAsSquare) ? imagefilledellipse( $this->image, (int)(($x * $this->scale) + ($this->scale / 2)), diff --git a/src/Output/QRImagick.php b/src/Output/QRImagick.php index 2b66a60cd..bd5d27828 100644 --- a/src/Output/QRImagick.php +++ b/src/Output/QRImagick.php @@ -123,7 +123,7 @@ class QRImagick extends QROutputAbstract{ $this->imagickDraw->setFillColor($this->moduleValues[$M_TYPE]); - $this->options->drawCircularModules && $this->matrix->checkTypeNotIn($x, $y, $this->options->keepAsSquare) + $this->options->drawCircularModules && !$this->matrix->checkTypeIn($x, $y, $this->options->keepAsSquare) ? $this->imagickDraw->circle( ($x + 0.5) * $this->scale, ($y + 0.5) * $this->scale, diff --git a/src/Output/QRMarkupSVG.php b/src/Output/QRMarkupSVG.php index 7c043b41d..9e7ebd41c 100644 --- a/src/Output/QRMarkupSVG.php +++ b/src/Output/QRMarkupSVG.php @@ -137,7 +137,7 @@ class QRMarkupSVG extends QRMarkup{ return ''; } - if($this->options->drawCircularModules && $this->matrix->checkTypeNotIn($x, $y, $this->options->keepAsSquare)){ + if($this->options->drawCircularModules && !$this->matrix->checkTypeIn($x, $y, $this->options->keepAsSquare)){ $r = $this->options->circleRadius; return sprintf( diff --git a/src/Output/QROutputAbstract.php b/src/Output/QROutputAbstract.php index cc6541ddf..1f8fa7162 100644 --- a/src/Output/QROutputAbstract.php +++ b/src/Output/QROutputAbstract.php @@ -163,7 +163,7 @@ abstract class QROutputAbstract implements QROutputInterface{ foreach($row as $x => $M_TYPE){ $M_TYPE_LAYER = $M_TYPE; - if($this->options->connectPaths && $this->matrix->checkTypeNotIn($x, $y, $this->options->excludeFromConnect)){ + if($this->options->connectPaths && !$this->matrix->checkTypeIn($x, $y, $this->options->excludeFromConnect)){ // to connect paths we'll redeclare the $M_TYPE_LAYER to data only $M_TYPE_LAYER = QRMatrix::M_DATA; diff --git a/tests/Data/QRMatrixTest.php b/tests/Data/QRMatrixTest.php index d218657c8..efffe813c 100755 --- a/tests/Data/QRMatrixTest.php +++ b/tests/Data/QRMatrixTest.php @@ -244,7 +244,7 @@ final class QRMatrixTest extends TestCase{ foreach($alignmentPattern as $py){ foreach($alignmentPattern as $px){ // skip finder pattern - if($matrix->checkTypeNotIn($px, $py, [QRMatrix::M_FINDER, QRMatrix::M_FINDER_DOT])){ + if(!$matrix->checkTypeIn($px, $py, [QRMatrix::M_FINDER, QRMatrix::M_FINDER_DOT])){ $this::assertSame(QRMatrix::M_ALIGNMENT | QRMatrix::IS_DARK, $matrix->get($px, $py)); } } @@ -272,7 +272,7 @@ final class QRMatrixTest extends TestCase{ for($i = 7; $i < $size - 7; $i++){ if($i % 2 === 0){ // skip alignment pattern - if($matrix->checkTypeNotIn(6, $i, [QRMatrix::M_ALIGNMENT])){ + if(!$matrix->checkTypeIn(6, $i, [QRMatrix::M_ALIGNMENT])){ $this::assertSame(QRMatrix::M_TIMING | QRMatrix::IS_DARK, $matrix->get(6, $i)); $this::assertSame(QRMatrix::M_TIMING | QRMatrix::IS_DARK, $matrix->get($i, 6)); } @@ -499,11 +499,11 @@ final class QRMatrixTest extends TestCase{ /** * Tests checking whether the M_TYPE of a module is not one of an array of M_TYPES */ - public function testCheckTypeNotIn():void{ + public function testCheckTypeIn():void{ $this->matrix->set(10, 10, true, QRMatrix::M_QUIETZONE); - $this::assertTrue($this->matrix->checkTypeNotIn(10, 10, [QRMatrix::M_DATA, QRMatrix::M_FINDER])); - $this::assertFalse($this->matrix->checkTypeNotIn(10, 10, [QRMatrix::M_QUIETZONE, QRMatrix::M_FINDER])); + $this::assertFalse($this->matrix->checkTypeIn(10, 10, [QRMatrix::M_DATA, QRMatrix::M_FINDER])); + $this::assertTrue($this->matrix->checkTypeIn(10, 10, [QRMatrix::M_QUIETZONE, QRMatrix::M_FINDER])); } /**