Documentation

QRMatrix
in package

Holds a numerical representation of the final QR Code; 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

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
$eccLevel  : EccLevel
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
a Version instance
__construct()  : mixed
QRMatrix constructor.
check()  : bool
Checks whether a module is true (dark) or false (light)
checkType()  : bool
Checks whether a module is of the given $M_TYPE
eccLevel()  : EccLevel
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]
init()  : self
shortcut to initialize the matrix
mapData()  : QRMatrix
Maps the binary $data array from QRData::maskECC() on the matrix, masking the data using $maskPattern (ISO/IEC 18004:2000 Section 8.8)
mask()  : self
Applies 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
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.
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
Returns the current version number

Constants

IS_DARK

public int IS_DARK = 0b100000000000

M_ALIGNMENT

public int M_ALIGNMENT = 0b10000

M_DARKMODULE

public int M_DARKMODULE = 0b1

M_FINDER_DOT

public int M_FINDER_DOT = 0b10000000000

M_FORMAT

public int M_FORMAT = 0b1000000

M_QUIETZONE

public int M_QUIETZONE = 0b100000000

M_SEPARATOR

public int M_SEPARATOR = 0b1000

M_TEST

public int M_TEST = 0b11111111111

M_VERSION

public int M_VERSION = 0b10000000

Properties

$maskPattern

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

private MaskPattern|null $maskPattern = null

$matrix

the actual matrix data array

private array<string|int, mixed> $matrix

$moduleCount

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

private int $moduleCount

Methods

check()

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

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

true => $value & 0x800 === 0x800 false => $value & 0x800 === 0

Parameters
$x : int
$y : int
Return values
bool

checkType()

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

flip()

Flips the value of the module

public flip(int $x, int $y) : self
Parameters
$x : int
$y : int
Return values
self

get()

Returns the value of the module at position [$x, $y]

public get(int $x, int $y) : int
Parameters
$x : int
$y : int
Return values
int

init()

shortcut to initialize the matrix

public init(MaskPattern $maskPattern[, bool $test = null ]) : self
Parameters
$maskPattern : MaskPattern
$test : bool = null
Return values
self

mapData()

Maps the binary $data array from QRData::maskECC() on the matrix, masking the data using $maskPattern (ISO/IEC 18004:2000 Section 8.8)

public mapData(SplFixedArray<string|int, int> $data) : QRMatrix
Parameters
$data : SplFixedArray<string|int, int>
Tags
see
QRData::maskECC()
Return values
QRMatrix

mask()

Applies the mask pattern

public mask(MaskPattern $maskPattern) : self

ISO/IEC 18004:2000 Section 8.8.1

Parameters
$maskPattern : MaskPattern
Return values
self

matrix()

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

set()

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

Draws the 5x5 alignment patterns

public setAlignmentPattern() : self

ISO/IEC 18004:2000 Section 7.3.5

Return values
self

setDarkModule()

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

public setDarkModule() : self
Return values
self

setFinderPattern()

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

Draws the format info along the finder patterns

public setFormatInfo(MaskPattern $maskPattern[, bool $test = null ]) : self

ISO/IEC 18004:2000 Section 8.9

Parameters
$maskPattern : MaskPattern
$test : bool = null
Return values
self

setLogoSpace()

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

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

Additionally, the logo space can be positioned within the QR Code - respecting the main functional patterns - 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.

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
$startX : int = null
$startY : int = null
Tags
link
https://github.com/chillerlan/php-qrcode/issues/52
throws
QRCodeDataException
Return values
self

setQuietZone()

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

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

ISO/IEC 18004:2000 Section 7.3.7

Parameters
$size : int = null
Tags
throws
QRCodeDataException
Return values
self

setSeparators()

Draws the separator lines around the finder patterns

public setSeparators() : self

ISO/IEC 18004:2000 Section 7.3.3

Return values
self

setTimingPattern()

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

Draws the version information, 2x 3x6 pixel

public setVersionNumber([bool $test = null ]) : self

ISO/IEC 18004:2000 Section 8.10

Parameters
$test : bool = null
Return values
self

size()

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

Search results