Explorar o código

:shower: rename QRMatrix::checkTypes() to checkTypeNotIn() and switch return value to better reflect what it actually does

smiley %!s(int64=3) %!d(string=hai) anos
pai
achega
1f435dfd54

+ 5 - 4
src/Data/QRMatrix.php

@@ -211,17 +211,18 @@ class QRMatrix{
 	}
 	}
 
 
 	/**
 	/**
-	 * checks whether a module matches one of the given $M_TYPES
+	 * 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.
 	 */
 	 */
-	public function checkTypes(int $x, int $y, array $M_TYPES):bool{
+	public function checkTypeNotIn(int $x, int $y, array $M_TYPES):bool{
 
 
 		foreach($M_TYPES as $type){
 		foreach($M_TYPES as $type){
 			if($this->checkType($x, $y, $type)){
 			if($this->checkType($x, $y, $type)){
-				return true;
+				return false;
 			}
 			}
 		}
 		}
 
 
-		return false;
+		return true;
 	}
 	}
 
 
 	/**
 	/**

+ 1 - 1
src/Output/QRGdImage.php

@@ -147,7 +147,7 @@ class QRGdImage extends QROutputAbstract{
 		/** @phan-suppress-next-line PhanParamTooFewInternalUnpack */
 		/** @phan-suppress-next-line PhanParamTooFewInternalUnpack */
 		$color = imagecolorallocate($this->image, ...$this->moduleValues[$M_TYPE]);
 		$color = imagecolorallocate($this->image, ...$this->moduleValues[$M_TYPE]);
 
 
-		$this->options->drawCircularModules && !$this->matrix->checkTypes($x, $y, $this->options->keepAsSquare)
+		$this->options->drawCircularModules && $this->matrix->checkTypeNotIn($x, $y, $this->options->keepAsSquare)
 			? imagefilledellipse(
 			? imagefilledellipse(
 				$this->image,
 				$this->image,
 				($x * $this->scale) + ($this->scale / 2),
 				($x * $this->scale) + ($this->scale / 2),

+ 1 - 1
src/Output/QRImagick.php

@@ -121,7 +121,7 @@ class QRImagick extends QROutputAbstract{
 		$this->imagickDraw->setStrokeColor($this->moduleValues[$M_TYPE]);
 		$this->imagickDraw->setStrokeColor($this->moduleValues[$M_TYPE]);
 		$this->imagickDraw->setFillColor($this->moduleValues[$M_TYPE]);
 		$this->imagickDraw->setFillColor($this->moduleValues[$M_TYPE]);
 
 
-		$this->options->drawCircularModules && !$this->matrix->checkTypes($x, $y, $this->options->keepAsSquare)
+		$this->options->drawCircularModules && $this->matrix->checkTypeNotIn($x, $y, $this->options->keepAsSquare)
 			? $this->imagickDraw->circle(
 			? $this->imagickDraw->circle(
 				($x + 0.5) * $this->scale,
 				($x + 0.5) * $this->scale,
 				($y + 0.5) * $this->scale,
 				($y + 0.5) * $this->scale,

+ 1 - 1
src/Output/QRMarkup.php

@@ -188,7 +188,7 @@ class QRMarkup extends QROutputAbstract{
 			return '';
 			return '';
 		}
 		}
 
 
-		if($this->options->drawCircularModules && !$this->matrix->checkTypes($x, $y, $this->options->keepAsSquare)){
+		if($this->options->drawCircularModules && $this->matrix->checkTypeNotIn($x, $y, $this->options->keepAsSquare)){
 			$r = $this->options->circleRadius;
 			$r = $this->options->circleRadius;
 
 
 			return sprintf(
 			return sprintf(

+ 1 - 1
src/Output/QROutputAbstract.php

@@ -142,7 +142,7 @@ abstract class QROutputAbstract implements QROutputInterface{
 		foreach($this->matrix->matrix() as $y => $row){
 		foreach($this->matrix->matrix() as $y => $row){
 			foreach($row as $x => $M_TYPE){
 			foreach($row as $x => $M_TYPE){
 
 
-				if($this->options->connectPaths && !$this->matrix->checkTypes($x, $y, $this->options->excludeFromConnect)){
+				if($this->options->connectPaths && $this->matrix->checkTypeNotIn($x, $y, $this->options->excludeFromConnect)){
 					// to connect paths we'll redeclare the $M_TYPE to data only
 					// to connect paths we'll redeclare the $M_TYPE to data only
 					$M_TYPE = QRMatrix::M_DATA;
 					$M_TYPE = QRMatrix::M_DATA;