Skip to content

Commit 1f435df

Browse files
committed
🚿 rename QRMatrix::checkTypes() to checkTypeNotIn() and switch return value to better reflect what it actually does
1 parent 9aad8fb commit 1f435df

File tree

5 files changed

+9
-8
lines changed

5 files changed

+9
-8
lines changed

src/Data/QRMatrix.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,17 +211,18 @@ public function checkType(int $x, int $y, int $M_TYPE):bool{
211211
}
212212

213213
/**
214-
* checks whether a module matches one of the given $M_TYPES
214+
* checks whether the module at ($x, $y) is not in the given array of $M_TYPES,
215+
* returns true if no matches are found, otherwise false.
215216
*/
216-
public function checkTypes(int $x, int $y, array $M_TYPES):bool{
217+
public function checkTypeNotIn(int $x, int $y, array $M_TYPES):bool{
217218

218219
foreach($M_TYPES as $type){
219220
if($this->checkType($x, $y, $type)){
220-
return true;
221+
return false;
221222
}
222223
}
223224

224-
return false;
225+
return true;
225226
}
226227

227228
/**

src/Output/QRGdImage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ protected function setPixel(int $x, int $y, int $M_TYPE):void{
147147
/** @phan-suppress-next-line PhanParamTooFewInternalUnpack */
148148
$color = imagecolorallocate($this->image, ...$this->moduleValues[$M_TYPE]);
149149

150-
$this->options->drawCircularModules && !$this->matrix->checkTypes($x, $y, $this->options->keepAsSquare)
150+
$this->options->drawCircularModules && $this->matrix->checkTypeNotIn($x, $y, $this->options->keepAsSquare)
151151
? imagefilledellipse(
152152
$this->image,
153153
($x * $this->scale) + ($this->scale / 2),

src/Output/QRImagick.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ protected function setPixel(int $x, int $y, int $M_TYPE):void{
121121
$this->imagickDraw->setStrokeColor($this->moduleValues[$M_TYPE]);
122122
$this->imagickDraw->setFillColor($this->moduleValues[$M_TYPE]);
123123

124-
$this->options->drawCircularModules && !$this->matrix->checkTypes($x, $y, $this->options->keepAsSquare)
124+
$this->options->drawCircularModules && $this->matrix->checkTypeNotIn($x, $y, $this->options->keepAsSquare)
125125
? $this->imagickDraw->circle(
126126
($x + 0.5) * $this->scale,
127127
($y + 0.5) * $this->scale,

src/Output/QRMarkup.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ protected function svgModule(int $x, int $y):string{
188188
return '';
189189
}
190190

191-
if($this->options->drawCircularModules && !$this->matrix->checkTypes($x, $y, $this->options->keepAsSquare)){
191+
if($this->options->drawCircularModules && $this->matrix->checkTypeNotIn($x, $y, $this->options->keepAsSquare)){
192192
$r = $this->options->circleRadius;
193193

194194
return sprintf(

src/Output/QROutputAbstract.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ protected function collectModules(Closure $transform):array{
142142
foreach($this->matrix->matrix() as $y => $row){
143143
foreach($row as $x => $M_TYPE){
144144

145-
if($this->options->connectPaths && !$this->matrix->checkTypes($x, $y, $this->options->excludeFromConnect)){
145+
if($this->options->connectPaths && $this->matrix->checkTypeNotIn($x, $y, $this->options->excludeFromConnect)){
146146
// to connect paths we'll redeclare the $M_TYPE to data only
147147
$M_TYPE = QRMatrix::M_DATA;
148148

0 commit comments

Comments
 (0)