mirror of
https://github.com/chillerlan/php-qrcode.git
synced 2026-08-25 08:27:57 +00:00
🚿 move file saving
This commit is contained in:
+8
-10
@@ -64,6 +64,8 @@ class QRImage extends QROutputAbstract{
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function dump(string $file = null):string{
|
||||
$file ??= $this->options->cachefile;
|
||||
|
||||
$this->image = imagecreatetruecolor($this->length, $this->length);
|
||||
|
||||
// avoid: Indirect modification of overloaded property $imageTransparencyBG has no effect
|
||||
@@ -83,7 +85,11 @@ class QRImage extends QROutputAbstract{
|
||||
}
|
||||
}
|
||||
|
||||
$imageData = $this->dumpImage($file);
|
||||
$imageData = $this->dumpImage();
|
||||
|
||||
if($file !== null){
|
||||
$this->saveToFile($imageData, $file);
|
||||
}
|
||||
|
||||
if((bool)$this->options->imageBase64){
|
||||
$imageData = sprintf('data:image/%s;base64,%s', $this->options->outputType, base64_encode($imageData));
|
||||
@@ -109,13 +115,9 @@ class QRImage extends QROutputAbstract{
|
||||
/**
|
||||
* @param string|null $file
|
||||
*
|
||||
* @return string
|
||||
|
||||
* @throws \chillerlan\QRCode\Output\QRCodeOutputException
|
||||
*/
|
||||
protected function dumpImage(string $file = null):string{
|
||||
$file ??= $this->options->cachefile;
|
||||
|
||||
protected function dumpImage():string{
|
||||
ob_start();
|
||||
|
||||
try{
|
||||
@@ -133,10 +135,6 @@ class QRImage extends QROutputAbstract{
|
||||
|
||||
ob_end_clean();
|
||||
|
||||
if($file !== null){
|
||||
$this->saveToFile($imageData, $file);
|
||||
}
|
||||
|
||||
return $imageData;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user