@@ -252,19 +252,14 @@ protected function saveToFile(string $data, string|null $file = null):void{
252252 }
253253
254254 /**
255- * collects the modules per QRMatrix::M_* type and runs a $ transform function on each module and
256- * returns an array with the transformed modules
255+ * collects the modules per QRMatrix::M_* type, runs a transform method on each module and
256+ * returns an array with the transformed modules.
257257 *
258- * The transform callback is called with the following parameters:
259- *
260- * $x - current column
261- * $y - current row
262- * $M_TYPE - field value
263- * $M_TYPE_LAYER - (possibly modified) field value that acts as layer id
258+ * @see \chillerlan\QRCode\Output\QROutputAbstract::moduleTransform()
264259 *
265260 * @return array<int, mixed>
266261 */
267- protected function collectModules (Closure $ transform ):array {
262+ protected function collectModules ():array {
268263 $ paths = [];
269264
270265 // collect the modules for each type
@@ -282,9 +277,9 @@ protected function collectModules(Closure $transform):array{
282277 }
283278
284279 // collect the modules per $M_TYPE
285- $ module = $ transform ($ x , $ y , $ M_TYPE , $ M_TYPE_LAYER );
280+ $ module = $ this -> moduleTransform ($ x , $ y , $ M_TYPE , $ M_TYPE_LAYER );
286281
287- if (! empty ( $ module) ){
282+ if ($ module !== null ){
288283 $ paths [$ M_TYPE_LAYER ][] = $ module ;
289284 }
290285 }
@@ -296,4 +291,21 @@ protected function collectModules(Closure $transform):array{
296291 return $ paths ;
297292 }
298293
294+ /**
295+ * The transform callback for the module collector
296+ *
297+ * $x - current column
298+ * $y - current row
299+ * $M_TYPE - field value
300+ * $M_TYPE_LAYER - (possibly modified) field value that acts as layer id ($paths array key)
301+ *
302+ * This method should return a value suitable for the current output class.
303+ * It must return `null` for an empty value.
304+ *
305+ * @see \chillerlan\QRCode\Output\QROutputAbstract::collectModules()
306+ */
307+ protected function moduleTransform (int $ x , int $ y , int $ M_TYPE , int $ M_TYPE_LAYER ):mixed {
308+ return null ;
309+ }
310+
299311}
0 commit comments