Skip to content

Commit 4f454cb

Browse files
committed
🚿 QROutputAbstract::collectModules(): don't mess with the field value, also add modified value as param to transform, docblock
1 parent 1f435df commit 4f454cb

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/Output/QROutputAbstract.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,25 +134,33 @@ protected function saveToFile(string $data, string $file):void{
134134
/**
135135
* collects the modules per QRMatrix::M_* type and runs a $transform functio on each module and
136136
* returns an array with the transformed modules
137+
*
138+
* The transform callback is called with the following parameters:
139+
*
140+
* $x - current column
141+
* $y - current row
142+
* $M_TYPE - field value
143+
* $M_TYPE_LAYER - (possibly modified) field value that acts as layer id
137144
*/
138145
protected function collectModules(Closure $transform):array{
139146
$paths = [];
140147

141148
// collect the modules for each type
142149
foreach($this->matrix->matrix() as $y => $row){
143150
foreach($row as $x => $M_TYPE){
151+
$M_TYPE_LAYER = $M_TYPE;
144152

145153
if($this->options->connectPaths && $this->matrix->checkTypeNotIn($x, $y, $this->options->excludeFromConnect)){
146-
// to connect paths we'll redeclare the $M_TYPE to data only
147-
$M_TYPE = QRMatrix::M_DATA;
154+
// to connect paths we'll redeclare the $M_TYPE_LAYER to data only
155+
$M_TYPE_LAYER = QRMatrix::M_DATA;
148156

149157
if($this->matrix->check($x, $y)){
150-
$M_TYPE |= QRMatrix::IS_DARK;
158+
$M_TYPE_LAYER |= QRMatrix::IS_DARK;
151159
}
152160
}
153161

154162
// collect the modules per $M_TYPE
155-
$paths[$M_TYPE][] = $transform($x, $y, $M_TYPE);
163+
$paths[$M_TYPE_LAYER][] = $transform($x, $y, $M_TYPE, $M_TYPE_LAYER);
156164
}
157165
}
158166

0 commit comments

Comments
 (0)