:octocat: +QROptions::$textLineStart and QROptions::$jsonAsBooleans output options

This commit is contained in:
smiley
2023-09-03 19:50:40 +02:00
parent bcd410a33b
commit f1008bd674
2 changed files with 17 additions and 7 deletions
+6 -5
View File
@@ -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);
}
//
+11 -2
View File
@@ -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