diff --git a/src/Output/QRString.php b/src/Output/QRString.php index 86bf966d4..4f64b5b49 100644 --- a/src/Output/QRString.php +++ b/src/Output/QRString.php @@ -7,7 +7,6 @@ * @copyright 2015 Smiley * @license MIT * - * @noinspection PhpUnusedParameterInspection * @noinspection PhpComposerExtensionStubsInspection */ @@ -65,7 +64,7 @@ class QRString extends QROutputAbstract{ * string output */ protected function text():string{ - $str = []; + $lines = []; for($y = 0; $y < $this->moduleCount; $y++){ $r = []; @@ -74,17 +73,19 @@ class QRString extends QROutputAbstract{ $r[] = $this->getModuleValueAt($x, $y); } - $str[] = implode('', $r); + $lines[] = $this->options->textLineStart.implode('', $r); } - return implode($this->options->eol, $str); + return implode($this->options->eol, $lines); } /** * JSON output + * + * @throws \JsonException */ protected function json():string{ - return json_encode($this->matrix->getMatrix(), JSON_THROW_ON_ERROR); + return json_encode($this->matrix->getMatrix($this->options->jsonAsBooleans), JSON_THROW_ON_ERROR); } // diff --git a/src/QROptionsTrait.php b/src/QROptionsTrait.php index 1058b929e..a698f3749 100644 --- a/src/QROptionsTrait.php +++ b/src/QROptionsTrait.php @@ -371,13 +371,22 @@ trait QROptionsTrait{ /** * String substitute for dark */ - protected string $textDark = '🔴'; + protected string $textDark = '██'; /** * String substitute for light */ - protected string $textLight = '⭕'; + protected string $textLight = '░░'; + /** + * An optional line prefix, e.g. empty space to align the QR Code in a console + */ + protected string $textLineStart = ''; + + /** + * Whether to return matrix values in JSON as booleans or $M_TYPE integers + */ + protected bool $jsonAsBooleans = false; /* * QRFpdf settings