QRStringJSON
extends QROutputAbstract
in package
uses
CssColorModuleValueTrait
JSON Output
Tags
Table of Contents
Constants
- MIME_TYPE = 'application/json'
- SCHEMA = 'https://raw.githubusercontent.com/chillerlan/php-qrcode/main/src/Output/qrcode.schema.json'
Properties
- $circleDiameter : float
- $circleRadius : float
- $connectPaths : bool
- $drawCircularModules : bool
- $drawLightModules : bool
- $eol : string
- $excludeFromConnect : array<string|int, int>
- $keepAsSquare : array<string|int, int>
- $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
Methods
- __construct() : mixed
- QROutputAbstract constructor.
- dump() : string
- Generates the output, optionally dumps it to a file, and returns it
- getModuleValue() : string
- Returns the prepared value for the given $M_TYPE
- 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 and runs a $transform function on each module and returns an array with the transformed modules
- copyVars() : void
- Creates copies of several QROptions values to avoid calling the magic getters in long loops for a significant performance increase.
- 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
- module() : array<string|int, mixed>|null
- Creates an array element for a single module
- prepareModuleValue() : string
- implements \chillerlan\QRCode\Output\QROutputAbstract::prepareModuleValue()
- row() : array<string|int, mixed>|null
- Creates an array element for a matrix row
- 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
Constants
MIME_TYPE
public
final mixed
MIME_TYPE
= 'application/json'
SCHEMA
public
final mixed
SCHEMA
= 'https://raw.githubusercontent.com/chillerlan/php-qrcode/main/src/Output/qrcode.schema.json'
Properties
$circleDiameter
protected
float
$circleDiameter
$circleRadius
protected
float
$circleRadius
Tags
$connectPaths
protected
bool
$connectPaths
Tags
$drawCircularModules
protected
bool
$drawCircularModules
Tags
$drawLightModules
protected
bool
$drawLightModules
Tags
$eol
protected
string
$eol
Tags
$excludeFromConnect
protected
array<string|int, int>
$excludeFromConnect
Tags
$keepAsSquare
protected
array<string|int, int>
$keepAsSquare
Tags
$length
the side length of the QR image (modules * scale)
protected
int
$length
$matrix
the (filled) data matrix object
protected
QRMatrix
$matrix
$moduleCount
the current size of the QR matrix
protected
int
$moduleCount
Tags
$moduleValues
an (optional) array of color values for the several QR matrix parts
protected
array<string|int, mixed>
$moduleValues
Tags
$options
the options instance
protected
SettingsContainerInterface|QROptions
$options
$scale
protected
int
$scale
Tags
Methods
__construct()
QROutputAbstract constructor.
public
__construct(SettingsContainerInterface|QROptions $options, QRMatrix $matrix) : mixed
Parameters
dump()
Generates the output, optionally dumps it to a file, and returns it
public
dump([string|null $file = null ]) : string
Parameters
- $file : string|null = null
Tags
Return values
stringgetModuleValue()
Returns the prepared value for the given $M_TYPE
public
getModuleValue([int $M_TYPE = ]) : string
Parameters
- $M_TYPE : int =
Return values
stringmoduleValueIsValid()
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
Return values
boolcollectModules()
collects the modules per QRMatrix::M_* type and runs a $transform function on each module and returns an array with the transformed modules
protected
collectModules(Closure $transform) : array<int, mixed>
The transform callback is called with the following parameters:
$x - current column $y - current row $M_TYPE - field value $M_TYPE_LAYER - (possibly modified) field value that acts as layer id
Parameters
- $transform : Closure
Return values
array<int, mixed>copyVars()
Creates copies of several QROptions values to avoid calling the magic getters in long loops for a significant performance increase.
protected
copyVars() : void
These variables are usually used in the "module" methods and are called up to 31329 times (at version 40).
getDefaultModuleValue()
implements \chillerlan\QRCode\Output\QROutputAbstract::getDefaultModuleValue()
protected
getDefaultModuleValue(bool $isDark) : string
Parameters
- $isDark : bool
Return values
stringgetModuleValue()
Returns the prepared value for the given $M_TYPE
protected
getModuleValue(int $M_TYPE) : mixed
Parameters
- $M_TYPE : int
Tags
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>
Tags
Return values
array<string|int, int>guessMimeType()
Guesses the mime type from the given $imageData
protected
guessMimeType(string $imageData) : string
Parameters
- $imageData : string
Tags
Return values
stringmodule()
Creates an array element for a single module
protected
module(int $x, int $y, int $M_TYPE) : array<string|int, mixed>|null
Parameters
- $x : int
- $y : int
- $M_TYPE : int
Tags
Return values
array<string|int, mixed>|nullprepareModuleValue()
implements \chillerlan\QRCode\Output\QROutputAbstract::prepareModuleValue()
protected
prepareModuleValue(string $value) : string
Parameters
- $value : string
Return values
stringrow()
Creates an array element for a matrix row
protected
row(int $y, array<string|int, int> $row) : array<string|int, mixed>|null
Parameters
- $y : int
- $row : array<string|int, int>
Tags
Return values
array<string|int, mixed>|nullsaveToFile()
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
setMatrixDimensions()
Sets/updates the matrix dimensions
protected
setMatrixDimensions() : void
Call this method if you modify the matrix from within your custom module 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