# Documentation

Menu

## BitMatrix extends QRMatrix
in package

FinalYes
BitMatrix.php : 23

Extended QRMatrix to map read data from the Binarizer

### Table of Contents

#### Constants

IS_DARK = 0b100000000000
M_ALIGNMENT = 0b10000
M_ALIGNMENT_DARK = 0b100000010000
M_DARKMODULE = 0b100000000001
M_DARKMODULE_LIGHT = 0b1
M_DATA = 0b10
M_DATA_DARK = 0b100000000010
M_FINDER = 0b100
M_FINDER_DARK = 0b100000000100
M_FINDER_DOT = 0b110000000000
M_FINDER_DOT_LIGHT = 0b10000000000
M_FORMAT = 0b1000000
M_FORMAT_DARK = 0b100001000000
M_LOGO = 0b1000000000
M_LOGO_DARK = 0b101000000000
M_NULL = 0b0
M_QUIETZONE = 0b100000000
M_QUIETZONE_DARK = 0b100100000000
M_SEPARATOR = 0b1000
M_SEPARATOR_DARK = 0b100000001000
M_TIMING = 0b100000
M_TIMING_DARK = 0b100000100000
M_VERSION = 0b10000000
M_VERSION_DARK = 0b100010000000
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

#### Properties

$eccLevel : EccLevel|null
  the current ECC level - always set in QRMatrix, may be null in BitMatrix
$maskPattern : MaskPattern|null
  the mask pattern that was used in the most recent operation, set via:
$matrix : array<string|int, array<string|int, int>>
  the actual matrix data array
$moduleCount : int
  the size (side length) of the matrix, including quiet zone (if created)
$version : Version|null
  the matrix version - always set in QRMatrix, may be null in BitMatrix
$mirror : bool
  This flag has effect only on the copyVersionBit() method.

#### Methods

__construct() : mixed
  QRMatrix constructor.
check() : bool
  Checks whether the module at ($x, $y) is true (dark) or false (light)
checkNeighbours() : int
  Checks the status of the neighbouring modules for the module at ($x, $y) and returns a bitmask with the results.
checkType() : bool
  Checks whether the module at ($x, $y) is of the given $M_TYPE
checkTypeIn() : bool
  Checks whether the module at ($x, $y) is in the given array of $M_TYPES, returns true if a match is found, otherwise false.
flip() : static
  Flips the value of the module at ($x, $y)
get() : int
  Returns the value of the module at position [$x, $y] or -1 if the coordinate is outside the matrix
getBooleanMatrix() : array<string|int, array<string|int, bool>>
  Returns a boolean representation of the data matrix
getEccLevel() : EccLevel|null
  Returns the current ECC level
getMaskPattern() : MaskPattern|null
  Returns the current mask pattern
getMatrix() : array<string|int, array<string|int, int>>
  Returns the data matrix
getSize() : int
  Returns the absoulute size of the matrix, including quiet zone (after setting it).
getVersion() : Version|null
  Returns the current version number
initFunctionalPatterns() : static
  shortcut to initialize the functional patterns
invert() : static
  Inverts the values of the whole matrix
isDark() : bool
  Checks whether the given $M_TYPE is a dark value
mask() : static
  Applies/reverses the mask pattern
mirrorDiagonal() : static
  Mirror the bit matrix diagonally in order to attempt a second reading.
readCodewords() : array<string|int, int>
  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.
resetVersionInfo() : static
  Resets the current version info in order to attempt another reading
rotate90() : static
  Rotates the matrix by 90 degrees clock wise
set() : static
  Sets the $M_TYPE value for the module at position [$x, $y]
setAlignmentPattern() : static
  Draws the 5x5 alignment patterns
setArea() : static
  Fills an area of $width * $height, from the given starting point [$startX, $startY] (top left) with $value for $M_TYPE.
setDarkModule() : static
  Sets the "dark module", that is always on the same position 1x1px away from the bottom left finder
setFinderPattern() : static
  Draws the 7x7 finder patterns in the corners top left/right and bottom left
setFormatInfo() : static
  Draws the format info along the finder patterns. If no $maskPattern, all format info modules will be set to false.
setLogoSpace() : static
  Clears a space of $width * $height in order to add a logo or text.
setQuietZone() : static
  Draws the "quiet zone" of $size around the matrix
setSeparators() : static
  Draws the separator lines around the finder patterns
setTimingPattern() : static
  Draws the timing pattern (h/v checkered line between the finder patterns)
setVersionNumber() : static
  Draws the version information, 2x 3x6 pixel
writeCodewords() : static
  Maps the interleaved binary $data on the matrix
createMatrix() : array<string|int, array<string|int, int>>
  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() : static
  Reads format information from one of its two locations within the QR Code.
readVersion() : static
  Reads version information from one of its two locations within the QR Code.
uRShift() : int

### Constants

#### IS_DARK

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

#### M_ALIGNMENT

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

#### M_ALIGNMENT_DARK

QRMatrix.php : 70
`public int M_ALIGNMENT_DARK = 0b100000010000`

#### M_DARKMODULE

QRMatrix.php : 64
`public int M_DARKMODULE = 0b100000000001`

#### M_DARKMODULE_LIGHT

QRMatrix.php : 85
`public int M_DARKMODULE_LIGHT = 0b1`

#### M_DATA

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

#### M_DATA_DARK

QRMatrix.php : 66
`public int M_DATA_DARK = 0b100000000010`

#### M_FINDER

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

#### M_FINDER_DARK

QRMatrix.php : 68
`public int M_FINDER_DARK = 0b100000000100`

#### M_FINDER_DOT

QRMatrix.php : 78
`public int M_FINDER_DOT = 0b110000000000`

#### M_FINDER_DOT_LIGHT

QRMatrix.php : 87
`public int M_FINDER_DOT_LIGHT = 0b10000000000`

#### M_FORMAT

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

#### M_FORMAT_DARK

QRMatrix.php : 74
`public int M_FORMAT_DARK = 0b100001000000`

#### M_LOGO

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

#### M_LOGO_DARK

QRMatrix.php : 36
`public int M_LOGO_DARK = 0b101000000000`

#### M_NULL

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

#### M_QUIETZONE

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

#### M_QUIETZONE_DARK

QRMatrix.php : 91
`public int M_QUIETZONE_DARK = 0b100100000000`

#### M_SEPARATOR

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

#### M_SEPARATOR_DARK

QRMatrix.php : 89
`public int M_SEPARATOR_DARK = 0b100000001000`

#### M_TIMING

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

#### M_TIMING_DARK

QRMatrix.php : 72
`public int M_TIMING_DARK = 0b100000100000`

#### M_VERSION

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

#### M_VERSION_DARK

QRMatrix.php : 76
`public int M_VERSION_DARK = 0b100010000000`

#### neighbours

QRMatrix.php : 100

Map of flag => coord

`protected array<string|int, array<string|int, int>> 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 : 30

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 : 65
`private mixed FORMAT_INFO_MASK_QR = 0x5412`

### Properties

#### $eccLevel

QRMatrix.php : 119

the current ECC level - always set in QRMatrix, may be null in BitMatrix

`protected EccLevel|null $eccLevel = null`

#### $maskPattern

QRMatrix.php : 128

the mask pattern that was used in the most recent operation, set via:

`protected MaskPattern|null $maskPattern = null`

- QRMatrix::setFormatInfo()
- QRMatrix::mask()
- BitMatrix::readFormatInformation()

#### $matrix

QRMatrix.php : 140

the actual matrix data array

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

#### $moduleCount

QRMatrix.php : 133

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

`protected int $moduleCount`

#### $version

QRMatrix.php : 114

the matrix version - always set in QRMatrix, may be null in BitMatrix

`protected Version|null $version = null`

#### $mirror

BitMatrix.php : 71

This flag has effect only on the copyVersionBit() method.

`private bool $mirror = false`

Before proceeding with readCodewords() the resetInfo() method should be called.

### Methods

#### __construct()

BitMatrix.php : 76

QRMatrix constructor.

`public __construct(int $dimension) : mixed`

##### Parameters

$dimension : int

##### Tags

noinspection

  PhpMissingParentConstructorInspection

#### check()

QRMatrix.php : 328

Checks whether the module at ($x, $y) is true (dark) or false (light)

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

Also, returns false if the given coordinates are out of range.

##### Parameters

$x : int
$y : int

##### Return values

bool

#### checkNeighbours()

QRMatrix.php : 354

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

`public checkNeighbours(int $x, int $y[, int|null $M_TYPE = 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:

0 1 2 7 # 3 6 5 4

##### Parameters

$x : int
$y : int
$M_TYPE : int|null = null

##### Return values

int

#### checkType()

QRMatrix.php : 297

Checks whether the module at ($x, $y) is of the given $M_TYPE

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

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

Also, returns false if the given coordinates are out of range.

##### Parameters

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

##### Return values

bool

#### checkTypeIn()

QRMatrix.php : 312

Checks whether the module at ($x, $y) is in the given array of $M_TYPES, returns true if a match is found, otherwise false.

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

##### Parameters

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

##### Return values

bool

#### flip()

QRMatrix.php : 281

Flips the value of the module at ($x, $y)

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

##### Parameters

$x : int
$y : int

##### Return values

static

#### get()

QRMatrix.php : 233

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

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

##### Parameters

$x : int
$y : int

##### Return values

int

#### getBooleanMatrix()

QRMatrix.php : 190

Returns a boolean representation of the data matrix

`public getBooleanMatrix() : array<string|int, array<string|int, bool>>`

##### Return values

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

#### getEccLevel()

QRMatrix.php : 210

Returns the current ECC level

`public getEccLevel() : EccLevel|null`

##### Return values

EccLevel|null

#### getMaskPattern()

QRMatrix.php : 217

Returns the current mask pattern

`public getMaskPattern() : MaskPattern|null`

##### Return values

MaskPattern|null

#### getMatrix()

QRMatrix.php : 181

Returns the data matrix

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

##### Return values

array<string|int, array<string|int, int>>

#### getSize()

QRMatrix.php : 226

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

`public getSize() : int`

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

##### Return values

int

#### getVersion()

QRMatrix.php : 203

Returns the current version number

`public getVersion() : Version|null`

##### Return values

Version|null

#### initFunctionalPatterns()

QRMatrix.php : 164

shortcut to initialize the functional patterns

`public initFunctionalPatterns() : static`

##### Return values

static

#### invert()

QRMatrix.php : 607

Inverts the values of the whole matrix

`public invert() : static`

ISO/IEC 18004:2015 Section 6.2 - Reflectance reversal

##### Return values

static

#### isDark()

QRMatrix.php : 340

Checks whether the given $M_TYPE is a dark value

`public isDark(int $M_TYPE) : bool`

##### Parameters

$M_TYPE : int

##### Return values

bool

#### mask()

QRMatrix.php : 761

Applies/reverses the mask pattern

`public mask(MaskPattern $maskPattern) : static`

ISO/IEC 18004:2000 Section 8.8.1

##### Parameters

$maskPattern : MaskPattern

##### Return values

static

#### mirrorDiagonal()

BitMatrix.php : 95

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

`public mirrorDiagonal() : static`

##### Return values

static

#### readCodewords()

BitMatrix.php : 112

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, int>`

##### Tags

throws
  QRCodeDecoderException

##### Return values

array<string|int, int>

#### resetVersionInfo()

BitMatrix.php : 84

Resets the current version info in order to attempt another reading

`public resetVersionInfo() : static`

##### Return values

static

#### rotate90()

QRMatrix.php : 596

Rotates the matrix by 90 degrees clock wise

`public rotate90() : static`

##### Return values

static

#### set()

QRMatrix.php : 248

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

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

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

##### Parameters

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

##### Return values

static

#### setAlignmentPattern()

QRMatrix.php : 446

Draws the 5x5 alignment patterns

`public setAlignmentPattern() : static`

ISO/IEC 18004:2000 Section 7.3.5

##### Return values

static

#### setArea()

QRMatrix.php : 267

Fills an area of $width * $height, from the given starting point [$startX, $startY] (top left) with $value for $M_TYPE.

`public setArea(int $startX, int $startY, int $width, int $height, bool $value, int $M_TYPE) : static`

##### Parameters

$startX : int
$startY : int
$width : int
$height : int
$value : bool
$M_TYPE : int

##### Return values

static

#### setDarkModule()

QRMatrix.php : 379

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

`public setDarkModule() : static`

4 * version + 9 or moduleCount - 8

##### Return values

static

#### setFinderPattern()

QRMatrix.php : 390

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

`public setFinderPattern() : static`

ISO/IEC 18004:2000 Section 7.3.2

##### Return values

static

#### setFormatInfo()

QRMatrix.php : 521

Draws the format info along the finder patterns. If no $maskPattern, all format info modules will be set to false.

`public setFormatInfo([MaskPattern|null $maskPattern = null ]) : static`

ISO/IEC 18004:2000 Section 8.9

##### Parameters

$maskPattern : MaskPattern|null = null

##### Return values

static

#### setLogoSpace()

BitMatrix.php : 417

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

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

##### Parameters

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

##### Tags

codeCoverageIgnore
throws
  QRCodeDataException

##### Return values

static

#### setQuietZone()

BitMatrix.php : 409

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

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

##### Parameters

$quietZoneSize : int|null = null

##### Tags

codeCoverageIgnore
throws
  QRCodeDataException

##### Return values

static

#### setSeparators()

QRMatrix.php : 415

Draws the separator lines around the finder patterns

`public setSeparators() : static`

ISO/IEC 18004:2000 Section 7.3.3

##### Return values

static

#### setTimingPattern()

QRMatrix.php : 475

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

`public setTimingPattern() : static`

ISO/IEC 18004:2000 Section 7.3.4

##### Return values

static

#### setVersionNumber()

QRMatrix.php : 497

Draws the version information, 2x 3x6 pixel

`public setVersionNumber() : static`

ISO/IEC 18004:2000 Section 8.10

##### Return values

static

#### writeCodewords()

QRMatrix.php : 708

Maps the interleaved binary $data on the matrix

`public writeCodewords(BitBuffer $bitBuffer) : static`

##### Parameters

$bitBuffer : BitBuffer

##### Return values

static

#### createMatrix()

QRMatrix.php : 157

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

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

##### Parameters

$size : int
$value : int

##### Return values

array<string|int, array<string|int, int>>

#### copyVersionBit()

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

##### Parameters

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

##### Return values

int

#### decodeVersionInformation()

BitMatrix.php : 349

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 : 253

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 : 390
`private numBitsDiffering(int $a, int $b) : int`

##### Parameters

$a : int
$b : int

##### Return values

int

#### readFormatInformation()

BitMatrix.php : 183

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

`private readFormatInformation() : static`

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

##### Tags

throws
  QRCodeDecoderException

##### Return values

static

#### readVersion()

BitMatrix.php : 297

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

`private readVersion() : static`

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

##### Tags

throws
  QRCodeDecoderException
noinspection

  DuplicatedCode

##### Return values

static

#### uRShift()

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

##### Parameters

$a : int
$b : int

##### Return values

int

## Search results