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 / QRMarkupHTML.php

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

40 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Class QRMarkupHTML
5 *
6 * @created 06.06.2022
7 * @author smiley <smiley@chillerlan.net>
8 * @copyright 2022 smiley
9 * @license MIT
10 */
11 namespace WCPOS\Vendor\chillerlan\QRCode\Output;
12
13 use function implode, sprintf;
14 /**
15 * HTML output (a cheap markup substitute when SVG is not available or not an option)
16 */
17 class QRMarkupHTML extends QRMarkup
18 {
19 public const MIME_TYPE = 'text/html';
20 /**
21 * @inheritDoc
22 */
23 protected function createMarkup(bool $saveToFile) : string
24 {
25 $rows = [];
26 $cssClass = $this->getCssClass();
27 foreach ($this->matrix->getMatrix() as $row) {
28 $element = '<span style="background: %s;"></span>';
29 $modules = \array_map(fn(int $M_TYPE): string => sprintf($element, $this->getModuleValue($M_TYPE)), $row);
30 $rows[] = sprintf('<div>%s</div>%s', implode('', $modules), $this->eol);
31 }
32 $html = sprintf('<div class="%1$s">%3$s%2$s</div>%3$s', $cssClass, implode('', $rows), $this->eol);
33 // wrap the snippet into a body when saving to file
34 if ($saveToFile) {
35 $html = sprintf('<!DOCTYPE html><html lang="none">%2$s<head>%2$s<meta charset="UTF-8">%2$s' . '<title>QR Code</title></head>%2$s<body>%1$s</body>%2$s</html>', $html, $this->eol);
36 }
37 return $html;
38 }
39 }
40