Documentation

QRMarkup extends QROutputAbstract
in package
uses CssColorModuleValueTrait

AbstractYes

Abstract for markup types: HTML, SVG, ... XML anyone?

Table of Contents

Properties

$length  : int
the side length of the QR image (modules * scale)
$matrix  : QRMatrix
the (filled) data matrix object
$moduleCount  : int
the current size of the QR matrix
$moduleValues  : array<string|int, mixed>
an (optional) array of color values for the several QR matrix parts
$options  : SettingsContainerInterface|QROptions
the options instance
$scale  : int
The current module scale value (might have been modified)

Methods

__construct()  : mixed
QROutputAbstract constructor.
dump()  : string
Generates the output, optionally dumps it to a file, and returns it
moduleValueIsValid()  : bool
note: we're not necessarily validating the several values, just checking the general syntax note: css4 colors are not included
collectModules()  : array<int, mixed>
collects the modules per QRMatrix::M_* type, runs a transform method on each module and returns an array with the transformed modules.
createMarkup()  : string
returns the fully parsed and rendered markup string for the given input
getCssClass()  : string
returns a string with all css classes for the current element
getDefaultModuleValue()  : string
implements \chillerlan\QRCode\Output\QROutputAbstract::getDefaultModuleValue()
getModuleValue()  : mixed
Returns the prepared value for the given $M_TYPE
getModuleValueAt()  : mixed
Returns the prepared module value at the given coordinate [$x, $y] (convenience)
getOutputDimensions()  : array<string|int, int>
Returns a 2 element array with the current output width and height
guessMimeType()  : string
Guesses the mime type from the given $imageData
moduleTransform()  : mixed
The transform callback for the module collector
prepareModuleValue()  : string
implements \chillerlan\QRCode\Output\QROutputAbstract::prepareModuleValue()
saveToFile()  : void
Saves the qr $data to a $file. If $file is null, nothing happens.
setMatrixDimensions()  : void
Sets/updates the matrix dimensions
setModuleValues()  : void
Sets the initial module values
toBase64DataURI()  : string
Returns a base64 data URI for the given string and mime type

Properties

$length

the side length of the QR image (modules * scale)

protected int $length

$moduleValues

an (optional) array of color values for the several QR matrix parts

protected array<string|int, mixed> $moduleValues
Tags
phpstan-var

array<int, mixed>

$scale

The current module scale value (might have been modified)

protected int $scale
Tags
see
QROptions::$scale

Methods

__construct()

QROutputAbstract constructor.

public __construct(SettingsContainerInterface|QROptions|iterable<string|int, mixed> $options, QRMatrix $matrix) : mixed
Parameters
$options : SettingsContainerInterface|QROptions|iterable<string|int, mixed>
$matrix : QRMatrix

dump()

Generates the output, optionally dumps it to a file, and returns it

public dump([string|null $file = null ]) : string

please note that the value of QROptions::$cachefile is already evaluated at this point. if the output module is invoked manually, it has no effect at all. you need to supply the $file parameter here in that case (or handle the option value in your custom output module).

Parameters
$file : string|null = null
Return values
string

moduleValueIsValid()

note: we're not necessarily validating the several values, just checking the general syntax note: css4 colors are not included

public static moduleValueIsValid(string $value) : bool

implements \chillerlan\QRCode\Output\QROutputInterface::moduleValueIsValid()

Parameters
$value : string
Tags
todo:

XSS proof

see
https://developer.mozilla.org/en-US/docs/Web/CSS/color_value
Return values
bool

collectModules()

collects the modules per QRMatrix::M_* type, runs a transform method on each module and returns an array with the transformed modules.

protected collectModules() : array<int, mixed>
Tags
see
QROutputAbstract::moduleTransform()
Return values
array<int, mixed>

createMarkup()

returns the fully parsed and rendered markup string for the given input

protected abstract createMarkup(bool $saveToFile) : string
Parameters
$saveToFile : bool
Return values
string

getCssClass()

returns a string with all css classes for the current element

protected getCssClass([int $M_TYPE = 0 ]) : string
Parameters
$M_TYPE : int = 0
Return values
string

getDefaultModuleValue()

implements \chillerlan\QRCode\Output\QROutputAbstract::getDefaultModuleValue()

protected getDefaultModuleValue(bool $isDark) : string
Parameters
$isDark : bool
Return values
string

getModuleValue()

Returns the prepared value for the given $M_TYPE

protected getModuleValue(int $M_TYPE) : mixed
Parameters
$M_TYPE : int
Tags
throws
QRCodeOutputException

if $moduleValues[$M_TYPE] doesn't exist

getModuleValueAt()

Returns the prepared module value at the given coordinate [$x, $y] (convenience)

protected getModuleValueAt(int $x, int $y) : mixed
Parameters
$x : int
$y : int

getOutputDimensions()

Returns a 2 element array with the current output width and height

protected getOutputDimensions() : array<string|int, int>

The type and units of the values depend on the output class. The default value is the current module count * scale.

Return values
array<string|int, int>

guessMimeType()

Guesses the mime type from the given $imageData

protected guessMimeType(string $imageData) : string
Parameters
$imageData : string
Tags
throws
QRCodeOutputException
Return values
string

moduleTransform()

The transform callback for the module collector

protected moduleTransform(int $x, int $y, int $M_TYPE, int $M_TYPE_LAYER) : mixed

$x - current column $y - current row $M_TYPE - field value $M_TYPE_LAYER - (possibly modified) field value that acts as layer id ($paths array key)

This method should return a value suitable for the current output class. It must return null for an empty value.

Parameters
$x : int
$y : int
$M_TYPE : int
$M_TYPE_LAYER : int
Tags
see
QROutputAbstract::collectModules()

prepareModuleValue()

implements \chillerlan\QRCode\Output\QROutputAbstract::prepareModuleValue()

protected prepareModuleValue(string $value) : string
Parameters
$value : string
Return values
string

saveToFile()

Saves the qr $data to a $file. If $file is null, nothing happens.

protected saveToFile(string $data[, string|null $file = null ]) : void
Parameters
$data : string
$file : string|null = null
Tags
see
file_put_contents()
see
QROptions::$cachefile
throws
QRCodeOutputException

setMatrixDimensions()

Sets/updates the matrix dimensions

protected setMatrixDimensions() : void

Call this method if you modify the matrix from within your custom output class in case the dimensions have been changed

setModuleValues()

Sets the initial module values

protected setModuleValues() : void

toBase64DataURI()

Returns a base64 data URI for the given string and mime type

protected toBase64DataURI(string $data[, string|null $mime = null ]) : string

The mime type can be set via class constant MIME_TYPE in child classes, or given via $mime, otherwise it is guessed from the image $data.

Parameters
$data : string
$mime : string|null = null
Return values
string

        
On this page

Search results