# Documentation

Menu

## QRMatrix
in package

QRMatrix.php : 22

Holds an array representation of the final QR Code that contains numerical values for later output modifications; maps the ECC coded binary data and applies the mask pattern

##### Tags

see
  http://www.thonky.com/qr-code-tutorial/format-version-information

### 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

#### 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

#### 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.
eccLevel() : EccLevel|null
flip() : self
  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
getEccLevel() : EccLevel|null
  Returns the current ECC level
getMaskPattern() : MaskPattern|null
  Returns the current mask pattern
getMatrix() : 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
getSize() : int
  Returns the absoulute size of the matrix, including quiet zone (after setting it).
getVersion() : Version|null
  Returns the current version number
initFunctionalPatterns() : self
  shortcut to initialize the functional patterns
invert() : self
  Inverts the values of the whole matrix
mask() : self
  Applies/reverses the mask pattern
maskPattern() : MaskPattern|null
matrix() : array<string|int, mixed>
rotate90() : self
  Rotates the matrix by 90 degrees clock wise
set() : self
  Sets the $M_TYPE value for the module at position [$x, $y]
setAlignmentPattern() : self
  Draws the 5x5 alignment patterns
setArea() : self
  Fills an area of $width * $height, from the given starting point [$startX, $startY] (top left) with $value for $M_TYPE.
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. If no $maskPattern, all format info modules will be set to false.
setLogoSpace() : self
  Clears a space of $width * $height in order to add a logo or text.
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
version() : Version|null
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

### Constants

#### IS_DARK

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

#### M_ALIGNMENT

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

#### M_ALIGNMENT_DARK

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

#### M_DARKMODULE

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

#### M_DARKMODULE_LIGHT

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

#### M_DATA

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

#### M_DATA_DARK

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

#### M_FINDER

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

#### M_FINDER_DARK

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

#### M_FINDER_DOT

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

#### M_FINDER_DOT_LIGHT

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

#### M_FORMAT

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

#### M_FORMAT_DARK

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

#### M_LOGO

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

#### M_LOGO_DARK

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

#### M_NULL

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

#### M_QUIETZONE

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

#### M_QUIETZONE_DARK

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

#### M_SEPARATOR

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

#### M_SEPARATOR_DARK

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

#### M_TIMING

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

#### M_TIMING_DARK

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

#### M_VERSION

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

#### M_VERSION_DARK

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

#### neighbours

QRMatrix.php : 99

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()

### Properties

#### $eccLevel

QRMatrix.php : 118

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

`protected EccLevel|null $eccLevel = null`

#### $maskPattern

QRMatrix.php : 127

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

the actual matrix data array

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

#### $moduleCount

QRMatrix.php : 132

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

`protected int $moduleCount`

#### $version

QRMatrix.php : 113

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

`protected Version|null $version = null`

### Methods

#### __construct()

QRMatrix.php : 144

QRMatrix constructor.

`public __construct(Version $version, EccLevel $eccLevel) : mixed`

##### Parameters

$version : Version
$eccLevel : EccLevel

#### check()

QRMatrix.php : 358

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

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

##### Parameters

$x : int
$y : int

##### Return values

bool

#### checkNeighbours()

QRMatrix.php : 372

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 $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

##### Return values

int

#### checkType()

QRMatrix.php : 330

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

##### Parameters

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

##### Return values

bool

#### checkTypeIn()

QRMatrix.php : 344

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, mixed> $M_TYPES) : bool`

##### Parameters

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

##### Return values

bool

#### eccLevel()

QRMatrix.php : 234
`public eccLevel() : EccLevel|null`

##### Tags

deprecated
  5.0.0

  use QRMatrix::getEccLevel() instead

see
  QRMatrix::getEccLevel()
codeCoverageIgnore

##### Return values

EccLevel|null

#### flip()

QRMatrix.php : 316

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

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

##### Parameters

$x : int
$y : int

##### Return values

self

#### get()

QRMatrix.php : 275

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

#### getEccLevel()

QRMatrix.php : 225

Returns the current ECC level

`public getEccLevel() : EccLevel|null`

##### Return values

EccLevel|null

#### getMaskPattern()

QRMatrix.php : 241

Returns the current mask pattern

`public getMaskPattern() : MaskPattern|null`

##### Return values

MaskPattern|null

#### getMatrix()

QRMatrix.php : 178

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

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

##### Parameters

$boolean : bool = null

##### Return values

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

#### getSize()

QRMatrix.php : 259

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

Returns the current version number

`public getVersion() : Version|null`

##### Return values

Version|null

#### initFunctionalPatterns()

QRMatrix.php : 161

shortcut to initialize the functional patterns

`public initFunctionalPatterns() : self`

##### Return values

self

#### invert()

QRMatrix.php : 618

Inverts the values of the whole matrix

`public invert() : self`

ISO/IEC 18004:2015 Section 6.2 - Reflectance reversal

##### Return values

self

#### mask()

QRMatrix.php : 767

Applies/reverses the mask pattern

`public mask(MaskPattern $maskPattern) : self`

ISO/IEC 18004:2000 Section 8.8.1

##### Parameters

$maskPattern : MaskPattern

##### Return values

self

#### maskPattern()

QRMatrix.php : 250
`public maskPattern() : MaskPattern|null`

##### Tags

deprecated
  5.0.0

  use QRMatrix::getMaskPattern() instead

see
  QRMatrix::getMaskPattern()
codeCoverageIgnore

##### Return values

MaskPattern|null

#### matrix()

QRMatrix.php : 202
`public matrix([bool $boolean = null ]) : array<string|int, mixed>`

##### Parameters

$boolean : bool = null

##### Tags

deprecated
  5.0.0

  use QRMatrix::getMatrix() instead

see
  QRMatrix::getMatrix()
codeCoverageIgnore

##### Return values

array<string|int, mixed>

#### rotate90()

QRMatrix.php : 606

Rotates the matrix by 90 degrees clock wise

`public rotate90() : self`

##### Return values

self

#### set()

QRMatrix.php : 290

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

Draws the 5x5 alignment patterns

`public setAlignmentPattern() : self`

ISO/IEC 18004:2000 Section 7.3.5

##### Return values

self

#### setArea()

QRMatrix.php : 302

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) : self`

##### Parameters

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

##### Return values

self

#### setDarkModule()

QRMatrix.php : 397

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

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

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

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

ISO/IEC 18004:2000 Section 8.9

##### Parameters

$maskPattern : MaskPattern = null

##### Return values

self

#### setLogoSpace()

QRMatrix.php : 657

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`

If no $height is given, the space will be assumed a square of $width.

Additionally, the logo space can be positioned within the QR Code using $startX and $startY. If either of these are null, the logo space will be centered in that direction. ECC level "H" (30%) is required.

The coordinates of $startX and $startY do not include the quiet zone: [0, 0] is always the top left module of the top left finder pattern, negative values go into the quiet zone top and left.

Please note that adding a logo space minimizes the error correction capacity of the QR Code and created images may become unreadable, especially when printed with a chance to receive damage. Please test thoroughly before using this feature in production.

This method should be called from within an output module (after the matrix has been filled with data). Note that there is no restiction on how many times this method could be called on the same matrix instance.

##### Parameters

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

##### Tags

link
  https://github.com/chillerlan/php-qrcode/issues/52
throws
  QRCodeDataException

##### Return values

self

#### setQuietZone()

QRMatrix.php : 579

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

`public setQuietZone(int $quietZoneSize) : self`

ISO/IEC 18004:2000 Section 7.3.7

##### Parameters

$quietZoneSize : int

##### Tags

throws
  QRCodeDataException

##### Return values

self

#### setSeparators()

QRMatrix.php : 432

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

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

Draws the version information, 2x 3x6 pixel

`public setVersionNumber() : self`

ISO/IEC 18004:2000 Section 8.10

##### Return values

self

#### size()

QRMatrix.php : 268
`public size() : int`

##### Tags

deprecated
  5.0.0

  use QRMatrix::getSize() instead

see
  QRMatrix::getSize()
codeCoverageIgnore

##### Return values

int

#### version()

QRMatrix.php : 218
`public version() : Version|null`

##### Tags

deprecated
  5.0.0

  use QRMatrix::getVersion() instead

see
  QRMatrix::getVersion()
codeCoverageIgnore

##### Return values

Version|null

#### writeCodewords()

QRMatrix.php : 720

Maps the interleaved binary $data on the matrix

`public writeCodewords(BitBuffer $bitBuffer) : self`

##### Parameters

$bitBuffer : BitBuffer

##### Return values

self

#### createMatrix()

QRMatrix.php : 154

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>

## Search results