Skip to content

Commit f1008bd

Browse files
committed
:octocat: +QROptions::$textLineStart and QROptions::$jsonAsBooleans output options
1 parent bcd410a commit f1008bd

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

src/Output/QRString.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
* @copyright 2015 Smiley
88
* @license MIT
99
*
10-
* @noinspection PhpUnusedParameterInspection
1110
* @noinspection PhpComposerExtensionStubsInspection
1211
*/
1312

@@ -65,7 +64,7 @@ public function dump(string $file = null):string{
6564
* string output
6665
*/
6766
protected function text():string{
68-
$str = [];
67+
$lines = [];
6968

7069
for($y = 0; $y < $this->moduleCount; $y++){
7170
$r = [];
@@ -74,17 +73,19 @@ protected function text():string{
7473
$r[] = $this->getModuleValueAt($x, $y);
7574
}
7675

77-
$str[] = implode('', $r);
76+
$lines[] = $this->options->textLineStart.implode('', $r);
7877
}
7978

80-
return implode($this->options->eol, $str);
79+
return implode($this->options->eol, $lines);
8180
}
8281

8382
/**
8483
* JSON output
84+
*
85+
* @throws \JsonException
8586
*/
8687
protected function json():string{
87-
return json_encode($this->matrix->getMatrix(), JSON_THROW_ON_ERROR);
88+
return json_encode($this->matrix->getMatrix($this->options->jsonAsBooleans), JSON_THROW_ON_ERROR);
8889
}
8990

9091
//

src/QROptionsTrait.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,13 +371,22 @@ trait QROptionsTrait{
371371
/**
372372
* String substitute for dark
373373
*/
374-
protected string $textDark = '🔴';
374+
protected string $textDark = '██';
375375

376376
/**
377377
* String substitute for light
378378
*/
379-
protected string $textLight = '';
379+
protected string $textLight = '░░';
380380

381+
/**
382+
* An optional line prefix, e.g. empty space to align the QR Code in a console
383+
*/
384+
protected string $textLineStart = '';
385+
386+
/**
387+
* Whether to return matrix values in JSON as booleans or $M_TYPE integers
388+
*/
389+
protected bool $jsonAsBooleans = false;
381390

382391
/*
383392
* QRFpdf settings

0 commit comments

Comments
 (0)