| 1 |
<?php |
| 2 |
/** |
| 3 |
* Class QRMarkup |
| 4 |
* |
| 5 |
* @created 17.12.2016 |
| 6 |
* @author Smiley <[email protected]> |
| 7 |
* @copyright 2016 Smiley |
| 8 |
* @license MIT |
| 9 |
*/ |
| 10 |
declare(strict_types=1); |
| 11 |
|
| 12 |
namespace chillerlan\QRCode\Output; |
| 13 |
|
| 14 |
/** |
| 15 |
* Abstract for markup types: HTML, SVG, ... XML anyone? |
| 16 |
*/ |
| 17 |
abstract class QRMarkup extends QROutputAbstract{ |
| 18 |
use CssColorModuleValueTrait; |
| 19 |
|
| 20 |
public function dump(string|null $file = null):string{ |
| 21 |
$saveToFile = $file !== null; |
| 22 |
$data = $this->createMarkup($saveToFile); |
| 23 |
|
| 24 |
$this->saveToFile($data, $file); |
| 25 |
|
| 26 |
// transform to data URI only when not saving to file |
| 27 |
if(!$saveToFile && $this->options->outputBase64){ |
| 28 |
return $this->toBase64DataURI($data); |
| 29 |
} |
| 30 |
|
| 31 |
return $data; |
| 32 |
} |
| 33 |
|
| 34 |
/** |
| 35 |
* returns a string with all css classes for the current element |
| 36 |
*/ |
| 37 |
protected function getCssClass(int $M_TYPE = 0):string{ |
| 38 |
return $this->options->cssClass; |
| 39 |
} |
| 40 |
|
| 41 |
/** |
| 42 |
* returns the fully parsed and rendered markup string for the given input |
| 43 |
*/ |
| 44 |
abstract protected function createMarkup(bool $saveToFile):string; |
| 45 |
|
| 46 |
} |