mirror of
https://github.com/chillerlan/php-qrcode.git
synced 2026-08-31 04:28:03 +00:00
:octocat: +QROptions::$textLineStart and QROptions::$jsonAsBooleans output options
This commit is contained in:
@@ -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
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user