PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.4.4
Booking for Appointments and Events Calendar – Amelia v2.4.4
2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / vendor / bacon / bacon-qr-code / src / Common / Mode.php
ameliabooking / vendor / bacon / bacon-qr-code / src / Common Last commit date
BitArray.php 8 months ago BitMatrix.php 8 months ago BitUtils.php 8 months ago CharacterSetEci.php 8 months ago EcBlock.php 8 months ago EcBlocks.php 8 months ago ErrorCorrectionLevel.php 8 months ago FormatInformation.php 8 months ago Mode.php 8 months ago ReedSolomonCodec.php 8 months ago Version.php 8 months ago
Mode.php
80 lines
1 <?php
2 declare(strict_types = 1);
3
4 namespace BaconQrCode\Common;
5
6 use DASPRiD\Enum\AbstractEnum;
7
8 /**
9 * Enum representing various modes in which data can be encoded to bits.
10 *
11 * @method static self TERMINATOR()
12 * @method static self NUMERIC()
13 * @method static self ALPHANUMERIC()
14 * @method static self STRUCTURED_APPEND()
15 * @method static self BYTE()
16 * @method static self ECI()
17 * @method static self KANJI()
18 * @method static self FNC1_FIRST_POSITION()
19 * @method static self FNC1_SECOND_POSITION()
20 * @method static self HANZI()
21 */
22 final class Mode extends AbstractEnum
23 {
24 protected const TERMINATOR = [[0, 0, 0], 0x00];
25 protected const NUMERIC = [[10, 12, 14], 0x01];
26 protected const ALPHANUMERIC = [[9, 11, 13], 0x02];
27 protected const STRUCTURED_APPEND = [[0, 0, 0], 0x03];
28 protected const BYTE = [[8, 16, 16], 0x04];
29 protected const ECI = [[0, 0, 0], 0x07];
30 protected const KANJI = [[8, 10, 12], 0x08];
31 protected const FNC1_FIRST_POSITION = [[0, 0, 0], 0x05];
32 protected const FNC1_SECOND_POSITION = [[0, 0, 0], 0x09];
33 protected const HANZI = [[8, 10, 12], 0x0d];
34
35 /**
36 * @var int[]
37 */
38 private $characterCountBitsForVersions;
39
40 /**
41 * @var int
42 */
43 private $bits;
44
45 /**
46 * @param int[] $characterCountBitsForVersions
47 */
48 protected function __construct(array $characterCountBitsForVersions, int $bits)
49 {
50 $this->characterCountBitsForVersions = $characterCountBitsForVersions;
51 $this->bits = $bits;
52 }
53
54 /**
55 * Returns the number of bits used in a specific QR code version.
56 */
57 public function getCharacterCountBits(Version $version) : int
58 {
59 $number = $version->getVersionNumber();
60
61 if ($number <= 9) {
62 $offset = 0;
63 } elseif ($number <= 26) {
64 $offset = 1;
65 } else {
66 $offset = 2;
67 }
68
69 return $this->characterCountBitsForVersions[$offset];
70 }
71
72 /**
73 * Returns the four bits used to encode this mode.
74 */
75 public function getBits() : int
76 {
77 return $this->bits;
78 }
79 }
80