:octocat: make QROutputInterface::moduleValueIsValid() public static

This commit is contained in:
smiley
2023-03-16 13:23:53 +01:00
parent d4887f2676
commit 76e90986e7
9 changed files with 20 additions and 20 deletions
+1 -1
View File
@@ -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;
}
+1 -1
View File
@@ -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;
+2 -2
View File
@@ -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);
+3 -3
View File
@@ -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);
}
+3 -3
View File
@@ -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);
}
+1 -1
View File
@@ -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);
}
+1 -8
View File
@@ -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)
*
+7
View File
@@ -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
*
+1 -1
View File
@@ -23,7 +23,7 @@ class QRString extends QROutputAbstract{
/**
* @inheritDoc
*/
protected function moduleValueIsValid($value):bool{
public static function moduleValueIsValid($value):bool{
return is_string($value);
}