PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.10.18
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.10.18
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 / Common / Mode.php

Mode.php in WCPOS – Point of Sale (POS) plugin for WooCommerce 1.10.18, at vendor_prefixed/chillerlan/php-qrcode/src/Common/Mode.php

77 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Class Mode
5 *
6 * @created 19.11.2020
7 * @author smiley <smiley@chillerlan.net>
8 * @copyright 2020 smiley
9 * @license MIT
10 */
11 namespace WCPOS\Vendor\chillerlan\QRCode\Common;
12
13 use WCPOS\Vendor\chillerlan\QRCode\Data\AlphaNum;
14 use WCPOS\Vendor\chillerlan\QRCode\Data\Byte;
15 use WCPOS\Vendor\chillerlan\QRCode\Data\Hanzi;
16 use WCPOS\Vendor\chillerlan\QRCode\Data\Kanji;
17 use WCPOS\Vendor\chillerlan\QRCode\Data\Number;
18 use WCPOS\Vendor\chillerlan\QRCode\QRCodeException;
19 /**
20 * Data mode information - ISO 18004:2006, 6.4.1, Tables 2 and 3
21 */
22 final class Mode
23 {
24 // ISO/IEC 18004:2000 Table 2
25 /** @var int */
26 public const TERMINATOR = 0b0;
27 /** @var int */
28 public const NUMBER = 0b1;
29 /** @var int */
30 public const ALPHANUM = 0b10;
31 /** @var int */
32 public const BYTE = 0b100;
33 /** @var int */
34 public const KANJI = 0b1000;
35 /** @var int */
36 public const HANZI = 0b1101;
37 /** @var int */
38 public const STRCTURED_APPEND = 0b11;
39 /** @var int */
40 public const FNC1_FIRST = 0b101;
41 /** @var int */
42 public const FNC1_SECOND = 0b1001;
43 /** @var int */
44 public const ECI = 0b111;
45 /**
46 * mode length bits for the version breakpoints 1-9, 10-26 and 27-40
47 *
48 * ISO/IEC 18004:2000 Table 3 - Number of bits in Character Count Indicator
49 */
50 public const LENGTH_BITS = [self::NUMBER => [10, 12, 14], self::ALPHANUM => [9, 11, 13], self::BYTE => [8, 16, 16], self::KANJI => [8, 10, 12], self::HANZI => [8, 10, 12], self::ECI => [0, 0, 0]];
51 /**
52 * Map of data mode => interface (detection order)
53 *
54 * @var string[]
55 */
56 public const INTERFACES = [self::NUMBER => Number::class, self::ALPHANUM => AlphaNum::class, self::KANJI => Kanji::class, self::HANZI => Hanzi::class, self::BYTE => Byte::class];
57 /**
58 * returns the length bits for the version breakpoints 1-9, 10-26 and 27-40
59 *
60 * @throws \chillerlan\QRCode\QRCodeException
61 */
62 public static function getLengthBitsForVersion(int $mode, int $version) : int
63 {
64 if (!isset(self::LENGTH_BITS[$mode])) {
65 throw new QRCodeException('invalid mode given');
66 }
67 $minVersion = 0;
68 foreach ([9, 26, 40] as $key => $breakpoint) {
69 if ($version > $minVersion && $version <= $breakpoint) {
70 return self::LENGTH_BITS[$mode][$key];
71 }
72 $minVersion = $breakpoint;
73 }
74 throw new QRCodeException(\sprintf('invalid version number: %d', $version));
75 }
76 }
77