Skip to content

Commit 76e9098

Browse files
committed
:octocat: make QROutputInterface::moduleValueIsValid() public static
1 parent d4887f2 commit 76e9098

File tree

9 files changed

+20
-20
lines changed

9 files changed

+20
-20
lines changed

examples/custom_output.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class MyCustomOutput extends QROutputAbstract{
2323
/**
2424
* @inheritDoc
2525
*/
26-
protected function moduleValueIsValid($value):bool{
26+
public static function moduleValueIsValid($value):bool{
2727
// TODO: Implement moduleValueIsValid() method. (abstract)
2828
return false;
2929
}

src/Output/QREps.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class QREps extends QROutputAbstract{
2525
/**
2626
* @inheritDoc
2727
*/
28-
protected function moduleValueIsValid($value):bool{
28+
public static function moduleValueIsValid($value):bool{
2929

3030
if(!is_array($value) || count($value) < 3){
3131
return false;

src/Output/QRFpdf.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function __construct(SettingsContainerInterface $options, QRMatrix $matri
4747
/**
4848
* @inheritDoc
4949
*/
50-
protected function moduleValueIsValid($value):bool{
50+
public static function moduleValueIsValid($value):bool{
5151

5252
if(!is_array($value) || count($value) < 3){
5353
return false;
@@ -94,7 +94,7 @@ public function dump(string $file = null){
9494
$fpdf = new FPDF('P', $this->options->fpdfMeasureUnit, [$this->length, $this->length]);
9595
$fpdf->AddPage();
9696

97-
if($this->moduleValueIsValid($this->options->bgColor)){
97+
if($this::moduleValueIsValid($this->options->bgColor)){
9898
$bgColor = $this->getModuleValue($this->options->bgColor);
9999
/** @phan-suppress-next-line PhanParamTooFewUnpack */
100100
$fpdf->SetFillColor(...$bgColor);

src/Output/QRGdImage.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function __construct(SettingsContainerInterface $options, QRMatrix $matri
8282
/**
8383
* @inheritDoc
8484
*/
85-
protected function moduleValueIsValid($value):bool{
85+
public static function moduleValueIsValid($value):bool{
8686

8787
if(!is_array($value) || count($value) < 3){
8888
return false;
@@ -185,7 +185,7 @@ protected function setBgColor():void{
185185
return;
186186
}
187187

188-
if($this->moduleValueIsValid($this->options->bgColor)){
188+
if($this::moduleValueIsValid($this->options->bgColor)){
189189
$this->background = $this->getModuleValue($this->options->bgColor);
190190

191191
return;
@@ -205,7 +205,7 @@ protected function setTransparencyColor():void{
205205

206206
$transparencyColor = $this->background;
207207

208-
if($this->moduleValueIsValid($this->options->transparencyColor)){
208+
if($this::moduleValueIsValid($this->options->transparencyColor)){
209209
$transparencyColor = $this->getModuleValue($this->options->transparencyColor);
210210
}
211211

src/Output/QRImagick.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function __construct(SettingsContainerInterface $options, QRMatrix $matri
6464
* @see https://www.php.net/manual/imagickpixel.construct.php
6565
* @inheritDoc
6666
*/
67-
protected function moduleValueIsValid($value):bool{
67+
public static function moduleValueIsValid($value):bool{
6868
return is_string($value);
6969
}
7070

@@ -124,7 +124,7 @@ protected function setBgColor():void{
124124
return;
125125
}
126126

127-
if($this->moduleValueIsValid($this->options->bgColor)){
127+
if($this::moduleValueIsValid($this->options->bgColor)){
128128
$this->background = $this->getModuleValue($this->options->bgColor);
129129

130130
return;
@@ -144,7 +144,7 @@ protected function setTransparencyColor():void{
144144

145145
$transparencyColor = $this->background;
146146

147-
if($this->moduleValueIsValid($this->options->transparencyColor)){
147+
if($this::moduleValueIsValid($this->options->transparencyColor)){
148148
$transparencyColor = $this->getModuleValue($this->options->transparencyColor);
149149
}
150150

src/Output/QRMarkup.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ abstract class QRMarkup extends QROutputAbstract{
2020
/**
2121
* @inheritDoc
2222
*/
23-
protected function moduleValueIsValid($value):bool{
23+
public static function moduleValueIsValid($value):bool{
2424
return is_string($value);
2525
}
2626

src/Output/QROutputAbstract.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,20 +84,13 @@ protected function setModuleValues():void{
8484
foreach($this::DEFAULT_MODULE_VALUES as $M_TYPE => $defaultValue){
8585
$value = ($this->options->moduleValues[$M_TYPE] ?? null);
8686

87-
$this->moduleValues[$M_TYPE] = $this->moduleValueIsValid($value)
87+
$this->moduleValues[$M_TYPE] = $this::moduleValueIsValid($value)
8888
? $this->getModuleValue($value)
8989
: $this->getDefaultModuleValue($defaultValue);
9090
}
9191

9292
}
9393

94-
/**
95-
* Determines whether the given value is valid
96-
*
97-
* @param mixed|null $value
98-
*/
99-
abstract protected function moduleValueIsValid($value):bool;
100-
10194
/**
10295
* Returns the final value for the given input (return value depends on the output module)
10396
*

src/Output/QROutputInterface.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ interface QROutputInterface{
8686
QRMatrix::M_TEST_DARK => true,
8787
];
8888

89+
/**
90+
* Determines whether the given value is valid
91+
*
92+
* @param mixed|null $value
93+
*/
94+
public static function moduleValueIsValid($value):bool;
95+
8996
/**
9097
* generates the output, optionally dumps it to a file, and returns it
9198
*

src/Output/QRString.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class QRString extends QROutputAbstract{
2323
/**
2424
* @inheritDoc
2525
*/
26-
protected function moduleValueIsValid($value):bool{
26+
public static function moduleValueIsValid($value):bool{
2727
return is_string($value);
2828
}
2929

0 commit comments

Comments
 (0)