diff --git a/src/Output/QRMarkup.php b/src/Output/QRMarkup.php index f7d52c1e0..e7cce5f88 100644 --- a/src/Output/QRMarkup.php +++ b/src/Output/QRMarkup.php @@ -20,10 +20,16 @@ abstract class QRMarkup extends QROutputAbstract{ * @inheritDoc */ public function dump(string $file = null):string{ - $data = $this->createMarkup($file !== null); + $saveToFile = $file !== null; + $data = $this->createMarkup($saveToFile); $this->saveToFile($data, $file); + // transform to data URI only when not saving to file + if(!$saveToFile && $this->options->outputBase64){ + return $this->toBase64DataURI($data); + } + return $data; } diff --git a/src/Output/QRMarkupSVG.php b/src/Output/QRMarkupSVG.php index e6264029e..9aa6961cf 100644 --- a/src/Output/QRMarkupSVG.php +++ b/src/Output/QRMarkupSVG.php @@ -83,11 +83,6 @@ class QRMarkupSVG extends QRMarkup{ // close svg $svg .= sprintf('%1$s%1$s', $this->eol); - // transform to data URI only when not saving to file - if(!$saveToFile && $this->options->outputBase64){ - return $this->toBase64DataURI($svg); - } - return $svg; } diff --git a/src/Output/QRMarkupXML.php b/src/Output/QRMarkupXML.php index 445a154f7..cf0c7613a 100644 --- a/src/Output/QRMarkupXML.php +++ b/src/Output/QRMarkupXML.php @@ -61,11 +61,6 @@ class QRMarkupXML extends QRMarkup{ $xml = $this->dom->saveXML(); - // transform to data URI only when not saving to file - if(!$saveToFile && $this->options->outputBase64){ - return $this->toBase64DataURI($xml); - } - return $xml; }