Explorar el Código

:octocat: QRMarkup: move base64 transformation to abstract

smiley hace 1 año
padre
commit
8276d6d6fb
Se han modificado 3 ficheros con 7 adiciones y 11 borrados
  1. 7 1
      src/Output/QRMarkup.php
  2. 0 5
      src/Output/QRMarkupSVG.php
  3. 0 5
      src/Output/QRMarkupXML.php

+ 7 - 1
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;
 	}
 

+ 0 - 5
src/Output/QRMarkupSVG.php

@@ -83,11 +83,6 @@ class QRMarkupSVG extends QRMarkup{
 		// close svg
 		$svg .= sprintf('%1$s</svg>%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;
 	}
 

+ 0 - 5
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;
 	}