FormatInformation
in package
Encapsulates a QR Code's format information, including the data mask used and error correction level.
Table of Contents
- BITS_SET_IN_HALF_BYTE = [0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4]
- Offset i holds the number of 1 bits in the binary representation of i.
- FORMAT_INFO_DECODE_LOOKUP = [[0x5412, 0x0], [0x5125, 0x1], [0x5e7c, 0x2], [0x5b4b, 0x3], [0x45f9, 0x4], [0x40ce, 0x5], [0x4f97, 0x6], [0x4aa0, 0x7], [0x77c4, 0x8], [0x72f3, 0x9], [0x7daa, 0xa], [0x789d, 0xb], [0x662f, 0xc], [0x6318, 0xd], [0x6c41, 0xe], [0x6976, 0xf], [0x1689, 0x10], [0x13be, 0x11], [0x1ce7, 0x12], [0x19d0, 0x13], [0x762, 0x14], [0x255, 0x15], [0xd0c, 0x16], [0x83b, 0x17], [0x355f, 0x18], [0x3068, 0x19], [0x3f31, 0x1a], [0x3a06, 0x1b], [0x24b4, 0x1c], [0x2183, 0x1d], [0x2eda, 0x1e], [0x2bed, 0x1f]]
- Lookup table for decoding format information.
- FORMAT_INFO_MASK_QR = 0x5412
- Mask for format information.
- $dataMask : int
- Data mask.
- $ecLevel : ErrorCorrectionLevel
- Error correction level.
- decodeFormatInformation() : self|null
- Decodes format information.
- equals() : bool
- Verifies if this instance equals another one.
- getDataMask() : int
- Returns the data mask.
- getErrorCorrectionLevel() : ErrorCorrectionLevel
- Returns the error correction level.
- hashCode() : int
- Hashes the code of the EC level.
- numBitsDiffering() : int
- Checks how many bits are different between two integers.
- __construct() : mixed
- doDecodeFormatInformation() : self|null
- Internal method for decoding format information.
Constants
BITS_SET_IN_HALF_BYTE
Offset i holds the number of 1 bits in the binary representation of i.
private
array<string|int, mixed>
BITS_SET_IN_HALF_BYTE
= [0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4]
FORMAT_INFO_DECODE_LOOKUP
Lookup table for decoding format information.
private
mixed
FORMAT_INFO_DECODE_LOOKUP
= [[0x5412, 0x0], [0x5125, 0x1], [0x5e7c, 0x2], [0x5b4b, 0x3], [0x45f9, 0x4], [0x40ce, 0x5], [0x4f97, 0x6], [0x4aa0, 0x7], [0x77c4, 0x8], [0x72f3, 0x9], [0x7daa, 0xa], [0x789d, 0xb], [0x662f, 0xc], [0x6318, 0xd], [0x6c41, 0xe], [0x6976, 0xf], [0x1689, 0x10], [0x13be, 0x11], [0x1ce7, 0x12], [0x19d0, 0x13], [0x762, 0x14], [0x255, 0x15], [0xd0c, 0x16], [0x83b, 0x17], [0x355f, 0x18], [0x3068, 0x19], [0x3f31, 0x1a], [0x3a06, 0x1b], [0x24b4, 0x1c], [0x2183, 0x1d], [0x2eda, 0x1e], [0x2bed, 0x1f]]
See ISO 18004:2006, Annex C, Table C.1
FORMAT_INFO_MASK_QR
Mask for format information.
private
mixed
FORMAT_INFO_MASK_QR
= 0x5412
Properties
$dataMask
Data mask.
private
int
$dataMask
$ecLevel
Error correction level.
private
ErrorCorrectionLevel
$ecLevel
Methods
decodeFormatInformation()
Decodes format information.
public
static decodeFormatInformation(int $maskedFormatInfo1, int $maskedFormatInfo2) : self|null
Parameters
- $maskedFormatInfo1 : int
- $maskedFormatInfo2 : int
Return values
self|null —equals()
Verifies if this instance equals another one.
public
equals(self $other) : bool
Parameters
- $other : self
Return values
bool —getDataMask()
Returns the data mask.
public
getDataMask() : int
Return values
int —getErrorCorrectionLevel()
Returns the error correction level.
public
getErrorCorrectionLevel() : ErrorCorrectionLevel
Return values
ErrorCorrectionLevel —hashCode()
Hashes the code of the EC level.
public
hashCode() : int
Return values
int —numBitsDiffering()
Checks how many bits are different between two integers.
public
static numBitsDiffering(int $a, int $b) : int
Parameters
- $a : int
- $b : int
Return values
int —__construct()
protected
__construct(int $formatInfo) : mixed
Parameters
- $formatInfo : int
Return values
mixed —doDecodeFormatInformation()
Internal method for decoding format information.
private
static doDecodeFormatInformation(int $maskedFormatInfo1, int $maskedFormatInfo2) : self|null
Parameters
- $maskedFormatInfo1 : int
- $maskedFormatInfo2 : int