change QRMatrix::checkTypeNotIn() to checkTypeIn()

This commit is contained in:
smiley
2023-03-09 19:08:37 +01:00
parent d21ed9d8ed
commit 61128e4aec
9 changed files with 17 additions and 17 deletions
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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;
+5 -5
View File
@@ -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;
}
/**
+1 -1
View File
@@ -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)),
+1 -1
View File
@@ -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,
+1 -1
View File
@@ -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(
+1 -1
View File
@@ -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;
+5 -5
View File
@@ -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]));
}
/**