mirror of
https://github.com/chillerlan/php-qrcode.git
synced 2026-10-09 21:35:53 +00:00
:octocat: QROutputAbstract::collectModules(): remove Closure parameter in favor of concrete method moduleTransform()
This commit is contained in:
@@ -32,7 +32,7 @@ class MeltedSVGQRCodeOutput extends QRMarkupSVG{
|
||||
return sprintf('<path class="%s" d="%s"/>', $this->getCssClass($M_TYPE), $path);
|
||||
}
|
||||
|
||||
protected function collectModules(Closure $transform):array{
|
||||
protected function collectModules():array{
|
||||
$paths = [];
|
||||
$melt = $this->options->melt; // avoid magic getter in long loops
|
||||
|
||||
@@ -57,7 +57,7 @@ class MeltedSVGQRCodeOutput extends QRMarkupSVG{
|
||||
}
|
||||
|
||||
// collect the modules per $M_TYPE
|
||||
$module = $transform($x, $y, $M_TYPE, $M_TYPE_LAYER);
|
||||
$module = $this->moduleTransform($x, $y, $M_TYPE, $M_TYPE_LAYER);
|
||||
|
||||
if(!empty($module)){
|
||||
$paths[$M_TYPE_LAYER][] = $module;
|
||||
@@ -71,7 +71,7 @@ class MeltedSVGQRCodeOutput extends QRMarkupSVG{
|
||||
return $paths;
|
||||
}
|
||||
|
||||
protected function module(int $x, int $y, int $M_TYPE):string{
|
||||
protected function moduleTransform(int $x, int $y, int $M_TYPE, int $M_TYPE_LAYER):string{
|
||||
$bits = $this->matrix->checkNeighbours($x, $y, null);
|
||||
$check = fn(int $all, int $any = 0):bool => ($bits & ($all | (~$any & 0xff))) === $all;
|
||||
|
||||
|
||||
@@ -42,11 +42,11 @@ class ModuleJitterSVGoutput extends QRMarkupSVG{
|
||||
return (random_int(0, PHP_INT_MAX) / PHP_INT_MAX);
|
||||
}
|
||||
|
||||
protected function module(int $x, int $y, int $M_TYPE):string{
|
||||
protected function moduleTransform(int $x, int $y, int $M_TYPE, int $M_TYPE_LAYER):string|null{
|
||||
|
||||
// skip light modules
|
||||
if((!$this->options->drawLightModules && !$this->matrix->check($x, $y))){
|
||||
return '';
|
||||
return null;
|
||||
}
|
||||
|
||||
// early exit on pure square modules
|
||||
|
||||
@@ -37,7 +37,7 @@ class RandomDotsSVGOutput extends QRMarkupSVG{
|
||||
*
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function collectModules(Closure $transform):array{
|
||||
protected function collectModules():array{
|
||||
$paths = [];
|
||||
$dotColors = $this->options->dotColors; // avoid magic getter in long loops
|
||||
|
||||
@@ -63,7 +63,7 @@ class RandomDotsSVGOutput extends QRMarkupSVG{
|
||||
}
|
||||
|
||||
// collect the modules per $M_TYPE
|
||||
$module = $transform($x, $y, $M_TYPE, $M_TYPE_LAYER);
|
||||
$module = $this->moduleTransform($x, $y, $M_TYPE, $M_TYPE_LAYER);
|
||||
|
||||
if(!empty($module)){
|
||||
$paths[$M_TYPE_LAYER][] = $module;
|
||||
|
||||
@@ -158,7 +158,7 @@ class RoundQuietzoneSVGoutput extends QRMarkupSVG{
|
||||
);
|
||||
}
|
||||
|
||||
protected function collectModules(Closure $transform):array{
|
||||
protected function collectModules():array{
|
||||
$paths = [];
|
||||
$dotColors = $this->options->dotColors; // avoid magic getter in long loops
|
||||
|
||||
@@ -184,7 +184,7 @@ class RoundQuietzoneSVGoutput extends QRMarkupSVG{
|
||||
}
|
||||
|
||||
// collect the modules per $M_TYPE
|
||||
$module = $transform($x, $y, $M_TYPE, $M_TYPE_LAYER);
|
||||
$module = $this->moduleTransform($x, $y, $M_TYPE, $M_TYPE_LAYER);
|
||||
|
||||
if(!empty($module)){
|
||||
$paths[$M_TYPE_LAYER][] = $module;
|
||||
|
||||
@@ -56,7 +56,7 @@ class QRSvgWithLogoAndCustomShapes extends QRMarkupSVG{
|
||||
*
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d
|
||||
*/
|
||||
protected function module(int $x, int $y, int $M_TYPE):string{
|
||||
protected function moduleTransform(int $x, int $y, int $M_TYPE, int $M_TYPE_LAYER):string|null{
|
||||
|
||||
if(
|
||||
!$this->matrix->isDark($M_TYPE)
|
||||
@@ -64,7 +64,7 @@ class QRSvgWithLogoAndCustomShapes extends QRMarkupSVG{
|
||||
|| $this->matrix->checkType($x, $y, QRMatrix::M_FINDER)
|
||||
|| $this->matrix->checkType($x, $y, QRMatrix::M_FINDER_DOT)
|
||||
){
|
||||
return '';
|
||||
return null;
|
||||
}
|
||||
|
||||
// return a heart shape (or any custom shape for that matter)
|
||||
|
||||
Reference in New Issue
Block a user