PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.9.15
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.9.15
1.10.19 1.10.18 1.10.17 1.10.16 1.10.15 1.10.13 1.10.14 1.10.12 1.10.11 1.10.10 1.10.9 1.10.8 untagged-3d9b7ccddc54df87c672 1.10.7 1.10.6 1.10.5 1.10.3 1.10.4 1.10.2 1.10.1 1.10.0 1.9.17 1.9.15 1.9.16 1.9.14 All 163 releases
woocommerce-pos / vendor_prefixed / chillerlan / php-qrcode / src / Output / QRStringText.php

QRStringText.php in WCPOS – Point of Sale (POS) plugin for WooCommerce 1.9.15, at vendor_prefixed/chillerlan/php-qrcode/src/Output/QRStringText.php

70 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Class QRStringText
5 *
6 * @created 25.10.2023
7 * @author smiley <smiley@chillerlan.net>
8 * @copyright 2023 smiley
9 * @license MIT
10 */
11 namespace WCPOS\Vendor\chillerlan\QRCode\Output;
12
13 use function array_map, implode, is_string, max, min, sprintf;
14 /**
15 *
16 */
17 class QRStringText extends QROutputAbstract
18 {
19 public const MIME_TYPE = 'text/plain';
20 /**
21 * @inheritDoc
22 */
23 public static function moduleValueIsValid($value) : bool
24 {
25 return is_string($value);
26 }
27 /**
28 * @inheritDoc
29 */
30 protected function prepareModuleValue($value) : string
31 {
32 return $value;
33 }
34 /**
35 * @inheritDoc
36 */
37 protected function getDefaultModuleValue(bool $isDark) : string
38 {
39 return $isDark ? '██' : '░░';
40 }
41 /**
42 * @inheritDoc
43 */
44 public function dump(?string $file = null) : string
45 {
46 $lines = [];
47 $linestart = $this->options->textLineStart;
48 foreach ($this->matrix->getMatrix() as $row) {
49 $lines[] = $linestart . implode('', array_map([$this, 'getModuleValue'], $row));
50 }
51 $data = implode($this->eol, $lines);
52 $this->saveToFile($data, $file);
53 return $data;
54 }
55 /**
56 * a little helper to create a proper ANSI 8-bit color escape sequence
57 *
58 * @see https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit
59 * @see https://en.wikipedia.org/wiki/Block_Elements
60 *
61 * @codeCoverageIgnore
62 */
63 public static function ansi8(string $str, int $color, ?bool $background = null) : string
64 {
65 $color = max(0, min($color, 255));
66 $background = $background === \true ? 48 : 38;
67 return sprintf("\x1b[%s;5;%sm%s\x1b[0m", $background, $color, $str);
68 }
69 }
70