Menu

## BitMatrix extends QRMatrix
in package

BitMatrix.php : 22

Extended QRMatrix to map read data from the Binarizer

### Table of Contents

IS_DARK = 0b100000000000
M_ALIGNMENT = 0b10000
M_DARKMODULE = 0b1
M_DATA = 0b10
M_FINDER = 0b100
M_FINDER_DOT = 0b10000000000
M_FORMAT = 0b1000000
M_LOGO = 0b1000000000
M_NULL = 0b0
M_QUIETZONE = 0b100000000
M_SEPARATOR = 0b1000
M_TEST = 0b11111111111
M_TIMING = 0b100000
M_VERSION = 0b10000000
neighbours = [0b1 => [-1, -1], 0b10 => [0, -1], 0b100 => [1, -1], 0b1000 => [1, 0], 0b10000 => [1, 1], 0b100000 => [0, 1], 0b1000000 => [-1, 1], 0b10000000 => [-1, 0]]
  Map of flag => coord
DECODE_LOOKUP = [ 0x5412, // 0101010000010010 0x5125, // 0101000100100101 0x5e7c, // 0101111001111100 0x5b4b, // 0101101101001011 0x45f9, // 0100010111111001 0x40ce, // 0100000011001110 0x4f97, // 0100111110010111 0x4aa0, // 0100101010100000 0x77c4, // 0111011111000100 0x72f3, // 0111001011110011 0x7daa, // 0111110110101010 0x789d, // 0111100010011101 0x662f, // 0110011000101111 0x6318, // 0110001100011000 0x6c41, // 0110110001000001 0x6976, // 0110100101110110 0x1689, // 0001011010001001 0x13be, // 0001001110111110 0x1ce7, // 0001110011100111 0x19d0, // 0001100111010000 0x762, // 0000011101100010 0x255, // 0000001001010101 0xd0c, // 0000110100001100 0x83b, // 0000100000111011 0x355f, // 0011010101011111 0x3068, // 0011000001101000 0x3f31, // 0011111100110001 0x3a06, // 0011101000000110 0x24b4, // 0010010010110100 0x2183, // 0010000110000011 0x2eda, // 0010111011011010 0x2bed, ]
  See ISO 18004:2006, Annex C, Table C.1
FORMAT_INFO_MASK_QR = 0x5412
$eccLevel : EccLevel|null
  the current ECC level
$maskPattern : MaskPattern|null
  the used mask pattern, set via QRMatrix::mask()
$matrix : array<string|int, mixed>
  the actual matrix data array
$moduleCount : int
  the size (side length) of the matrix, including quiet zone (if created)
$version : Version|null
  a Version instance
$mirror : bool
__construct() : mixed
  QRMatrix constructor.
check() : bool
  Checks whether a module is true (dark) or false (light)
checkNeighbours() : int
  Checks the status neighbouring modules of the given module at ($x, $y) and returns a bitmask with the results.
checkType() : bool
  Checks whether a module is of the given $M_TYPE
checkTypeNotIn() : bool
  checks whether the module at ($x, $y) is not in the given array of $M_TYPES, returns true if no matches are found, otherwise false.
eccLevel() : EccLevel|null
  Returns the current ECC level
flip() : self
  Flips the value of the module
get() : int
  Returns the value of the module at position [$x, $y] or -1 if the coordinate is outside of the matrix
initFunctionalPatterns() : self
  shortcut to initialize the functional patterns
mask() : self
  Applies/reverses the mask pattern
maskPattern() : MaskPattern|null
  Returns the current mask pattern
matrix() : array<string|int, array<string|int, int>>|array<string|int, array<string|int, bool>>
  Returns the data matrix, returns a pure boolean representation if $boolean is set to true
mirror() : self
  Mirror the bit matrix in order to attempt a second reading.
readCodewords() : array<string|int, mixed>
  Reads the bits in the BitMatrix representing the finder pattern in the correct order in order to reconstruct the codewords bytes contained within the QR Code. Throws if the exact number of bytes expected is not read.
set() : self
  Sets the $M_TYPE value for the module at position [$x, $y]
setAlignmentPattern() : self
  Draws the 5x5 alignment patterns
setDarkModule() : self
  Sets the "dark module", that is always on the same position 1x1px away from the bottom left finder
setFinderPattern() : self
  Draws the 7x7 finder patterns in the corners top left/right and bottom left
setFormatInfo() : self
  Draws the format info along the finder patterns
setLogoSpace() : self
  Clears a space of $width * $height in order to add a logo or text.
setMirror() : self
  Prepare the parser for a mirrored operation.
setQuietZone() : self
  Draws the "quiet zone" of $size around the matrix
setSeparators() : self
  Draws the separator lines around the finder patterns
setTimingPattern() : self
  Draws the timing pattern (h/v checkered line between the finder patterns)
setVersionNumber() : self
  Draws the version information, 2x 3x6 pixel
size() : int
  Returns the absoulute size of the matrix, including quiet zone (after setting it).
version() : Version|null
  Returns the current version number
writeCodewords() : self
  Maps the interleaved binary $data on the matrix
createMatrix() : array<string|int, mixed>
  Creates a 2-dimensional array (square) of the given $size
copyVersionBit() : int
decodeVersionInformation() : Version|null
  Decodes the version information from the given bit sequence, returns null if no valid match is found.
doDecodeFormatInformation() : int|null
  Returns information about the format it specifies, or null if it doesn't seem to match any known pattern
numBitsDiffering() : int
readFormatInformation() : self
  Reads format information from one of its two locations within the QR Code.
readVersion() : self
  Reads version information from one of its two locations within the QR Code.
uRShift() : int

### Constants

#### IS_DARK

QRMatrix.php : 51
`public int IS_DARK = 0b100000000000`

#### M_ALIGNMENT

QRMatrix.php : 35
`public int M_ALIGNMENT = 0b10000`

#### M_DARKMODULE

QRMatrix.php : 27
`public int M_DARKMODULE = 0b1`

#### M_DATA

QRMatrix.php : 29
`public int M_DATA = 0b10`

#### M_FINDER

QRMatrix.php : 31
`public int M_FINDER = 0b100`

#### M_FINDER_DOT

QRMatrix.php : 47
`public int M_FINDER_DOT = 0b10000000000`

#### M_FORMAT

QRMatrix.php : 39
`public int M_FORMAT = 0b1000000`

#### M_LOGO

QRMatrix.php : 45
`public int M_LOGO = 0b1000000000`

#### M_NULL

QRMatrix.php : 25
`public int M_NULL = 0b0`

#### M_QUIETZONE

QRMatrix.php : 43
`public int M_QUIETZONE = 0b100000000`

#### M_SEPARATOR

QRMatrix.php : 33
`public int M_SEPARATOR = 0b1000`

#### M_TEST

QRMatrix.php : 49
`public int M_TEST = 0b11111111111`

#### M_TIMING

QRMatrix.php : 37
`public int M_TIMING = 0b100000`

#### M_VERSION

QRMatrix.php : 41
`public int M_VERSION = 0b10000000`

#### neighbours

QRMatrix.php : 60

Map of flag => coord

`protected array<string|int, mixed> neighbours = [0b1 => [-1, -1], 0b10 => [0, -1], 0b100 => [1, -1], 0b1000 => [1, 0], 0b10000 => [1, 1], 0b100000 => [0, 1], 0b1000000 => [-1, 1], 0b10000000 => [-1, 0]]`

##### Tags

see
  QRMatrix::checkNeighbours()

#### DECODE_LOOKUP

BitMatrix.php : 29

See ISO 18004:2006, Annex C, Table C.1

`private mixed DECODE_LOOKUP = [ 0x5412, // 0101010000010010 0x5125, // 0101000100100101 0x5e7c, // 0101111001111100 0x5b4b, // 0101101101001011 0x45f9, // 0100010111111001 0x40ce, // 0100000011001110 0x4f97, // 0100111110010111 0x4aa0, // 0100101010100000 0x77c4, // 0111011111000100 0x72f3, // 0111001011110011 0x7daa, // 0111110110101010 0x789d, // 0111100010011101 0x662f, // 0110011000101111 0x6318, // 0110001100011000 0x6c41, // 0110110001000001 0x6976, // 0110100101110110 0x1689, // 0001011010001001 0x13be, // 0001001110111110 0x1ce7, // 0001110011100111 0x19d0, // 0001100111010000 0x762, // 0000011101100010 0x255, // 0000001001010101 0xd0c, // 0000110100001100 0x83b, // 0000100000111011 0x355f, // 0011010101011111 0x3068, // 0011000001101000 0x3f31, // 0011111100110001 0x3a06, // 0011101000000110 0x24b4, // 0010010010110100 0x2183, // 0010000110000011 0x2eda, // 0010111011011010 0x2bed, ]`

[data bits, sequence after masking]

#### FORMAT_INFO_MASK_QR

BitMatrix.php : 64
`private mixed FORMAT_INFO_MASK_QR = 0x5412`

### Properties

#### $eccLevel

QRMatrix.php : 79

the current ECC level

`protected EccLevel|null $eccLevel = null`

#### $maskPattern

QRMatrix.php : 74

the used mask pattern, set via QRMatrix::mask()

`protected MaskPattern|null $maskPattern = null`

#### $matrix

QRMatrix.php : 96

the actual matrix data array

`protected array<string|int, mixed> $matrix`

#### $moduleCount

QRMatrix.php : 89

the size (side length) of the matrix, including quiet zone (if created)

`protected int $moduleCount`

#### $version

QRMatrix.php : 84

a Version instance

`protected Version|null $version = null`

#### $mirror

BitMatrix.php : 66
`private bool $mirror = false`

### Methods

#### __construct()

BitMatrix.php : 71

QRMatrix constructor.

`public __construct(int $dimension) : mixed`

##### Parameters

$dimension : int

##### Tags

noinspection

  PhpMissingParentConstructorInspection

##### Return values

mixed —

#### check()

QRMatrix.php : 256

Checks whether a module is true (dark) or false (light)

`public check(int $x, int $y) : bool`

##### Parameters

$x : int
$y : int

##### Return values

bool —

#### checkNeighbours()

QRMatrix.php : 270

Checks the status neighbouring modules of the given module at ($x, $y) and returns a bitmask with the results.

`public checkNeighbours(int $x, int $y[, int $M_TYPE_VALUE = null ]) : int`

The 8 flags of the bitmask represent the status of each of the neighbouring fields, starting with the lowest bit for top left, going clockwise:

1 2 3 8 # 4 7 6 5

##### Parameters

$x : int
$y : int
$M_TYPE_VALUE : int = null

##### Return values

int —

#### checkType()

QRMatrix.php : 229

Checks whether a module is of the given $M_TYPE

`public checkType(int $x, int $y, int $M_TYPE) : bool`

true => $value & $M_TYPE === $M_TYPE

##### Parameters

$x : int
$y : int
$M_TYPE : int

##### Return values

bool —

#### checkTypeNotIn()

QRMatrix.php : 242

checks whether the module at ($x, $y) is not in the given array of $M_TYPES, returns true if no matches are found, otherwise false.

`public checkTypeNotIn(int $x, int $y, array<string|int, mixed> $M_TYPES) : bool`

##### Parameters

$x : int
$y : int
$M_TYPES : array<string|int, mixed>

##### Return values

bool —

#### eccLevel()

QRMatrix.php : 165

Returns the current ECC level

`public eccLevel() : EccLevel|null`

##### Return values

EccLevel|null —

#### flip()

QRMatrix.php : 215

Flips the value of the module

`public flip(int $x, int $y) : self`

##### Parameters

$x : int
$y : int

##### Return values

self —

#### get()

QRMatrix.php : 188

Returns the value of the module at position [$x, $y] or -1 if the coordinate is outside of the matrix

`public get(int $x, int $y) : int`

##### Parameters

$x : int
$y : int

##### Return values

int —

#### initFunctionalPatterns()

QRMatrix.php : 119

shortcut to initialize the functional patterns

`public initFunctionalPatterns() : self`

##### Return values

self —

#### mask()

QRMatrix.php : 644

Applies/reverses the mask pattern

`public mask() : self`

ISO/IEC 18004:2000 Section 8.8.1

##### Return values

self —

#### maskPattern()

QRMatrix.php : 172

Returns the current mask pattern

`public maskPattern() : MaskPattern|null`

##### Return values

MaskPattern|null —

#### matrix()

QRMatrix.php : 136

Returns the data matrix, returns a pure boolean representation if $boolean is set to true

`public matrix([bool $boolean = false ]) : array<string|int, array<string|int, int>>|array<string|int, array<string|int, bool>>`

##### Parameters

$boolean : bool = false

##### Return values

array<string|int, array<string|int, int>>|array<string|int, array<string|int, bool>> —

#### mirror()

BitMatrix.php : 94

Mirror the bit matrix in order to attempt a second reading.

`public mirror() : self`

##### Return values

self —

#### readCodewords()

BitMatrix.php : 115

Reads the bits in the BitMatrix representing the finder pattern in the correct order in order to reconstruct the codewords bytes contained within the QR Code. Throws if the exact number of bytes expected is not read.

`public readCodewords() : array<string|int, mixed>`

##### Tags

throws
  QRCodeDecoderException

##### Return values

array<string|int, mixed> —

#### set()

QRMatrix.php : 203

Sets the $M_TYPE value for the module at position [$x, $y]

`public set(int $x, int $y, bool $value, int $M_TYPE) : self`

true => $M_TYPE | 0x800 false => $M_TYPE

##### Parameters

$x : int
$y : int
$value : bool
$M_TYPE : int

##### Return values

self —

#### setAlignmentPattern()

QRMatrix.php : 370

Draws the 5x5 alignment patterns

`public setAlignmentPattern() : self`

ISO/IEC 18004:2000 Section 7.3.5

##### Return values

self —

#### setDarkModule()

QRMatrix.php : 294

Sets the "dark module", that is always on the same position 1x1px away from the bottom left finder

`public setDarkModule() : self`

4 * version + 9 or moduleCount - 8

##### Return values

self —

#### setFinderPattern()

QRMatrix.php : 305

Draws the 7x7 finder patterns in the corners top left/right and bottom left

`public setFinderPattern() : self`

ISO/IEC 18004:2000 Section 7.3.2

##### Return values

self —

#### setFormatInfo()

QRMatrix.php : 447

Draws the format info along the finder patterns

`public setFormatInfo() : self`

ISO/IEC 18004:2000 Section 8.9

##### Return values

self —

#### setLogoSpace()

BitMatrix.php : 426

Clears a space of $width * $height in order to add a logo or text.

`public setLogoSpace(int $width[, int $height = null ][, int $startX = null ][, int $startY = null ]) : self`

##### Parameters

$width : int
$height : int = null
$startX : int = null
$startY : int = null

##### Tags

codeCoverageIgnore
throws
  QRCodeDataException

##### Return values

self —

#### setMirror()

BitMatrix.php : 82

Prepare the parser for a mirrored operation.

`public setMirror(bool $mirror) : self`

This flag has effect only on the readFormatInformation() and the readVersion() methods. Before proceeding with readCodewords() the mirror() method should be called.

##### Parameters

$mirror : bool

##### Return values

self —

#### setQuietZone()

BitMatrix.php : 418

Draws the "quiet zone" of $size around the matrix

`public setQuietZone([int $quietZoneSize = null ]) : self`

##### Parameters

$quietZoneSize : int = null

##### Tags

codeCoverageIgnore
throws
  QRCodeDataException

##### Return values

self —

#### setSeparators()

QRMatrix.php : 340

Draws the separator lines around the finder patterns

`public setSeparators() : self`

ISO/IEC 18004:2000 Section 7.3.3

##### Return values

self —

#### setTimingPattern()

QRMatrix.php : 401

Draws the timing pattern (h/v checkered line between the finder patterns)

`public setTimingPattern() : self`

ISO/IEC 18004:2000 Section 7.3.4

##### Return values

self —

#### setVersionNumber()

QRMatrix.php : 423

Draws the version information, 2x 3x6 pixel

`public setVersionNumber() : self`

ISO/IEC 18004:2000 Section 8.10

##### Return values

self —

#### size()

QRMatrix.php : 181

Returns the absoulute size of the matrix, including quiet zone (after setting it).

`public size() : int`

size = version * 4 + 17 [ + 2 * quietzone size]

##### Return values

int —

#### version()

QRMatrix.php : 158

Returns the current version number

`public version() : Version|null`

##### Return values

Version|null —

#### writeCodewords()

QRMatrix.php : 597

Maps the interleaved binary $data on the matrix

`public writeCodewords(BitBuffer $bitBuffer) : self`

##### Parameters

$bitBuffer : BitBuffer

##### Return values

self —

#### createMatrix()

QRMatrix.php : 112

Creates a 2-dimensional array (square) of the given $size

`protected createMatrix(int $size, int $value) : array<string|int, mixed>`

##### Parameters

$size : int
$value : int

##### Return values

array<string|int, mixed> —

#### copyVersionBit()

BitMatrix.php : 243
`private copyVersionBit(int $i, int $j, int $versionBits) : int`

##### Parameters

$i : int
$j : int
$versionBits : int

##### Return values

int —

#### decodeVersionInformation()

BitMatrix.php : 351

Decodes the version information from the given bit sequence, returns null if no valid match is found.

`private decodeVersionInformation(int $versionBits) : Version|null`

##### Parameters

$versionBits : int

##### Return values

Version|null —

#### doDecodeFormatInformation()

BitMatrix.php : 255

Returns information about the format it specifies, or null if it doesn't seem to match any known pattern

`private doDecodeFormatInformation(int $maskedFormatInfo1, int $maskedFormatInfo2) : int|null`

##### Parameters

$maskedFormatInfo1 : int
$maskedFormatInfo2 : int

##### Return values

int|null —

#### numBitsDiffering()

BitMatrix.php : 399
`private numBitsDiffering(int $a, int $b) : int`

##### Parameters

$a : int
$b : int

##### Return values

int —

#### readFormatInformation()

BitMatrix.php : 182

Reads format information from one of its two locations within the QR Code.

`private readFormatInformation() : self`

Throws if both format information locations cannot be parsed as the valid encoding of format information.

##### Tags

throws
  QRCodeDecoderException

##### Return values

self —

#### readVersion()

BitMatrix.php : 299

Reads version information from one of its two locations within the QR Code.

`private readVersion() : self`

Throws if both version information locations cannot be parsed as the valid encoding of version information.

##### Tags

throws
  QRCodeDecoderException
noinspection

  DuplicatedCode

##### Return values

self —

#### uRShift()

BitMatrix.php : 387
`private uRShift(int $a, int $b) : int`

##### Parameters

$a : int
$b : int

##### Return values

int —

## Search results