# Documentation

Menu

## QRMarkupSVG extends QRMarkup
in package

QRMarkupSVG.php : 27

SVG output

##### Tags

see
  https://github.com/codemasher/php-qrcode/pull/5
see
  https://developer.mozilla.org/en-US/docs/Web/SVG
see
  https://www.sarasoueidan.com/demos/interactive-svg-coordinate-system/
see
  https://lea.verou.me/blog/2019/05/utility-convert-svg-path-to-all-relative-or-all-absolute-commands/
see
  https://codepen.io/leaverou/full/RmwzKv
see
  https://jakearchibald.github.io/svgomg/
see
  https://web.archive.org/web/20200220211445/http://apex.infogridpacific.com/SVG/svg-tutorial-contents.html

### Table of Contents

#### Constants

MIME_TYPE = 'image/svg+xml'

#### 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
moduleValueIsValid() : bool
  Determines whether the given value is valid
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.
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
getViewBox() : string
  returns the value for the SVG viewBox attribute
guessMimeType() : string
  Guesses the mime type from the given $imageData
header() : string
  returns the <svg> header with the given options parsed
module() : string
  returns a path segment for a single module
path() : string
  renders and returns a single <path> element
paths() : string
  returns one or more SVG <path> elements
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

### Constants

#### MIME_TYPE

QRMarkupSVG.php : 29
`public final mixed MIME_TYPE = 'image/svg+xml'`

### Properties

#### $circleDiameter

QROutputAbstract.php : 79
`protected float $circleDiameter`

#### $circleRadius

QROutputAbstract.php : 78
`protected float $circleRadius`

##### Tags

see
  QROptions::$circleRadius

#### $connectPaths

QROutputAbstract.php : 70
`protected bool $connectPaths`

##### Tags

see
  QROptions::$connectPaths

#### $drawCircularModules

QROutputAbstract.php : 76
`protected bool $drawCircularModules`

##### Tags

see
  QROptions::$drawCircularModules

#### $drawLightModules

QROutputAbstract.php : 74
`protected bool $drawLightModules`

##### Tags

see
  QROptions::$drawLightModules

#### $eol

QROutputAbstract.php : 72
`protected string $eol`

##### Tags

see
  QROptions::$eol

#### $excludeFromConnect

QROutputAbstract.php : 61
`protected array<string|int, int> $excludeFromConnect`

##### Tags

see
  QROptions::$excludeFromConnect

#### $keepAsSquare

QROutputAbstract.php : 66
`protected array<string|int, int> $keepAsSquare`

##### Tags

see
  QROptions::$keepAsSquare

#### $length

QROutputAbstract.php : 38

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

`protected int $length`

#### $matrix

QROutputAbstract.php : 50

the (filled) data matrix object

`protected QRMatrix $matrix`

#### $moduleCount

QROutputAbstract.php : 33

the current size of the QR matrix

`protected int $moduleCount`

##### Tags

see
  QRMatrix::getSize()

#### $moduleValues

QROutputAbstract.php : 45

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

`protected array<string|int, mixed> $moduleValues`

##### Tags

phpstan-var

  array<int, mixed>

#### $options

QROutputAbstract.php : 55

the options instance

`protected SettingsContainerInterface|QROptions $options`

#### $scale

QROutputAbstract.php : 68
`protected int $scale`

##### Tags

see
  QROptions::$scale

### Methods

#### __construct()

QROutputAbstract.php : 84

QROutputAbstract constructor.

`public __construct(SettingsContainerInterface|QROptions $options, QRMatrix $matrix) : mixed`

##### Parameters

$options : SettingsContainerInterface|QROptions
$matrix : QRMatrix

#### dump()

QRMarkup.php : 20

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

QRMarkupSVG.php : 37

Determines whether the given value is valid

`public static moduleValueIsValid(mixed $value) : bool`

##### Parameters

$value : mixed

##### Tags

todo:

  XSS proof

see
  https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/fill
inheritDoc

##### Return values

bool

#### collectModules()

QROutputAbstract.php : 267

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

QROutputAbstract.php : 103

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

#### createMarkup()

QRMarkupSVG.php : 66

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

`protected createMarkup(bool $saveToFile) : string`

##### Parameters

$saveToFile : bool

##### Return values

string

#### getCssClass()

QRMarkupSVG.php : 58

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

CssColorModuleValueTrait.php : 73

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

`protected getDefaultModuleValue(bool $isDark) : string`

##### Parameters

$isDark : bool

##### Return values

string

#### getModuleValue()

QROutputAbstract.php : 179

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

QROutputAbstract.php : 191

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

QRMarkupSVG.php : 54

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>

#### getViewBox()

QRMarkupSVG.php : 87

returns the value for the SVG viewBox attribute

`protected getViewBox() : string`

##### Tags

see
  https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/viewBox
see
  https://css-tricks.com/scale-svg/#article-header-id-3

##### Return values

string

#### guessMimeType()

QROutputAbstract.php : 216

Guesses the mime type from the given $imageData

`protected guessMimeType(string $imageData) : string`

##### Parameters

$imageData : string

##### Tags

throws
  QRCodeOutputException

##### Return values

string

#### header()

QRMarkupSVG.php : 98

returns the <svg> header with the given options parsed

`protected header() : string`

##### Tags

see
  https://developer.mozilla.org/en-US/docs/Web/SVG/Element/svg

##### Return values

string

#### module()

QRMarkupSVG.php : 168

returns a path segment for a single module

`protected module(int $x, int $y, int $M_TYPE) : string`

##### Parameters

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

##### Tags

see
  https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d

##### Return values

string

#### path()

QRMarkupSVG.php : 149

renders and returns a single <path> element

`protected path(string $path, int $M_TYPE) : string`

##### Parameters

$path : string
$M_TYPE : int

##### Tags

see
  https://developer.mozilla.org/en-US/docs/Web/SVG/Element/path

##### Return values

string

#### paths()

QRMarkupSVG.php : 118

returns one or more SVG <path> elements

`protected paths() : string`

##### Return values

string

#### prepareModuleValue()

CssColorModuleValueTrait.php : 66

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

`protected prepareModuleValue(string $value) : string`

##### Parameters

$value : string

##### Return values

string

#### saveToFile()

QROutputAbstract.php : 239

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

QROutputAbstract.php : 127

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

QROutputAbstract.php : 147

Sets the initial module values

`protected setModuleValues() : void`

#### toBase64DataURI()

QROutputAbstract.php : 201

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

## Search results