mirror of
https://github.com/chillerlan/php-qrcode.git
synced 2026-08-31 20:48:40 +00:00
:octocat: make QROutputInterface::moduleValueIsValid() public static
This commit is contained in:
@@ -23,7 +23,7 @@ class MyCustomOutput extends QROutputAbstract{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function moduleValueIsValid($value):bool{
|
||||
public static function moduleValueIsValid($value):bool{
|
||||
// TODO: Implement moduleValueIsValid() method. (abstract)
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ class QREps extends QROutputAbstract{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function moduleValueIsValid($value):bool{
|
||||
public static function moduleValueIsValid($value):bool{
|
||||
|
||||
if(!is_array($value) || count($value) < 3){
|
||||
return false;
|
||||
|
||||
@@ -47,7 +47,7 @@ class QRFpdf extends QROutputAbstract{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function moduleValueIsValid($value):bool{
|
||||
public static function moduleValueIsValid($value):bool{
|
||||
|
||||
if(!is_array($value) || count($value) < 3){
|
||||
return false;
|
||||
@@ -94,7 +94,7 @@ class QRFpdf extends QROutputAbstract{
|
||||
$fpdf = new FPDF('P', $this->options->fpdfMeasureUnit, [$this->length, $this->length]);
|
||||
$fpdf->AddPage();
|
||||
|
||||
if($this->moduleValueIsValid($this->options->bgColor)){
|
||||
if($this::moduleValueIsValid($this->options->bgColor)){
|
||||
$bgColor = $this->getModuleValue($this->options->bgColor);
|
||||
/** @phan-suppress-next-line PhanParamTooFewUnpack */
|
||||
$fpdf->SetFillColor(...$bgColor);
|
||||
|
||||
@@ -82,7 +82,7 @@ class QRGdImage extends QROutputAbstract{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function moduleValueIsValid($value):bool{
|
||||
public static function moduleValueIsValid($value):bool{
|
||||
|
||||
if(!is_array($value) || count($value) < 3){
|
||||
return false;
|
||||
@@ -185,7 +185,7 @@ class QRGdImage extends QROutputAbstract{
|
||||
return;
|
||||
}
|
||||
|
||||
if($this->moduleValueIsValid($this->options->bgColor)){
|
||||
if($this::moduleValueIsValid($this->options->bgColor)){
|
||||
$this->background = $this->getModuleValue($this->options->bgColor);
|
||||
|
||||
return;
|
||||
@@ -205,7 +205,7 @@ class QRGdImage extends QROutputAbstract{
|
||||
|
||||
$transparencyColor = $this->background;
|
||||
|
||||
if($this->moduleValueIsValid($this->options->transparencyColor)){
|
||||
if($this::moduleValueIsValid($this->options->transparencyColor)){
|
||||
$transparencyColor = $this->getModuleValue($this->options->transparencyColor);
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ class QRImagick extends QROutputAbstract{
|
||||
* @see https://www.php.net/manual/imagickpixel.construct.php
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function moduleValueIsValid($value):bool{
|
||||
public static function moduleValueIsValid($value):bool{
|
||||
return is_string($value);
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ class QRImagick extends QROutputAbstract{
|
||||
return;
|
||||
}
|
||||
|
||||
if($this->moduleValueIsValid($this->options->bgColor)){
|
||||
if($this::moduleValueIsValid($this->options->bgColor)){
|
||||
$this->background = $this->getModuleValue($this->options->bgColor);
|
||||
|
||||
return;
|
||||
@@ -144,7 +144,7 @@ class QRImagick extends QROutputAbstract{
|
||||
|
||||
$transparencyColor = $this->background;
|
||||
|
||||
if($this->moduleValueIsValid($this->options->transparencyColor)){
|
||||
if($this::moduleValueIsValid($this->options->transparencyColor)){
|
||||
$transparencyColor = $this->getModuleValue($this->options->transparencyColor);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ abstract class QRMarkup extends QROutputAbstract{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function moduleValueIsValid($value):bool{
|
||||
public static function moduleValueIsValid($value):bool{
|
||||
return is_string($value);
|
||||
}
|
||||
|
||||
|
||||
@@ -84,20 +84,13 @@ abstract class QROutputAbstract implements QROutputInterface{
|
||||
foreach($this::DEFAULT_MODULE_VALUES as $M_TYPE => $defaultValue){
|
||||
$value = ($this->options->moduleValues[$M_TYPE] ?? null);
|
||||
|
||||
$this->moduleValues[$M_TYPE] = $this->moduleValueIsValid($value)
|
||||
$this->moduleValues[$M_TYPE] = $this::moduleValueIsValid($value)
|
||||
? $this->getModuleValue($value)
|
||||
: $this->getDefaultModuleValue($defaultValue);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the given value is valid
|
||||
*
|
||||
* @param mixed|null $value
|
||||
*/
|
||||
abstract protected function moduleValueIsValid($value):bool;
|
||||
|
||||
/**
|
||||
* Returns the final value for the given input (return value depends on the output module)
|
||||
*
|
||||
|
||||
@@ -86,6 +86,13 @@ interface QROutputInterface{
|
||||
QRMatrix::M_TEST_DARK => true,
|
||||
];
|
||||
|
||||
/**
|
||||
* Determines whether the given value is valid
|
||||
*
|
||||
* @param mixed|null $value
|
||||
*/
|
||||
public static function moduleValueIsValid($value):bool;
|
||||
|
||||
/**
|
||||
* generates the output, optionally dumps it to a file, and returns it
|
||||
*
|
||||
|
||||
@@ -23,7 +23,7 @@ class QRString extends QROutputAbstract{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function moduleValueIsValid($value):bool{
|
||||
public static function moduleValueIsValid($value):bool{
|
||||
return is_string($value);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user