PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.10.20
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.10.20
1.10.20 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 All 164 releases
woocommerce-pos / vendor_prefixed / chillerlan / php-qrcode / src / Output / QRMarkup.php

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

85 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Class QRMarkup
5 *
6 * @created 17.12.2016
7 * @author Smiley <[email protected]>
8 * @copyright 2016 Smiley
9 * @license MIT
10 */
11 namespace WCPOS\Vendor\chillerlan\QRCode\Output;
12
13 use function is_string, preg_match, strip_tags, trim;
14 /**
15 * Abstract for markup types: HTML, SVG, ... XML anyone?
16 */
17 abstract class QRMarkup extends QROutputAbstract
18 {
19 /**
20 * note: we're not necessarily validating the several values, just checking the general syntax
21 * note: css4 colors are not included
22 *
23 * @todo: XSS proof
24 *
25 * @see https://developer.mozilla.org/en-US/docs/Web/CSS/color_value
26 * @inheritDoc
27 */
28 public static function moduleValueIsValid($value) : bool
29 {
30 if (!is_string($value)) {
31 return \false;
32 }
33 $value = trim(strip_tags($value), " '\"\r\n\t");
34 // hex notation
35 // #rgb(a)
36 // #rrggbb(aa)
37 if (preg_match('/^#([\\da-f]{3}){1,2}$|^#([\\da-f]{4}){1,2}$/i', $value)) {
38 return \true;
39 }
40 // css: hsla/rgba(...values)
41 if (preg_match('#^(hsla?|rgba?)\\([\\d .,%/]+\\)$#i', $value)) {
42 return \true;
43 }
44 // predefined css color
45 if (preg_match('/^[a-z]+$/i', $value)) {
46 return \true;
47 }
48 return \false;
49 }
50 /**
51 * @inheritDoc
52 */
53 protected function prepareModuleValue($value) : string
54 {
55 return trim(strip_tags($value), " '\"\r\n\t");
56 }
57 /**
58 * @inheritDoc
59 */
60 protected function getDefaultModuleValue(bool $isDark) : string
61 {
62 return $isDark ? '#000' : '#fff';
63 }
64 /**
65 * @inheritDoc
66 */
67 public function dump(?string $file = null) : string
68 {
69 $data = $this->createMarkup($file !== null);
70 $this->saveToFile($data, $file);
71 return $data;
72 }
73 /**
74 * returns a string with all css classes for the current element
75 */
76 protected function getCssClass(int $M_TYPE = 0) : string
77 {
78 return $this->options->cssClass;
79 }
80 /**
81 * returns the fully parsed and rendered markup string for the given input
82 */
83 protected abstract function createMarkup(bool $saveToFile) : string;
84 }
85