MMOframework
Pourquoi l'IA Playground Bibliothèques Développeurs Agence
FR EN
Créer un projet en direct
Index

QrCode

MMO\oauth\helpers · 1 symbole · générée le 30 Nov 2026

class

QrCode

QrCode.php:14

A QR code (ISO/IEC 18004) of a short text, as an SVG: the otpauth:// link an authenticator app scans to enrol a second factor (Totp::Uri). No dependency, and nothing sent to a third party (a QR code service would see the secret). Byte mode, error correction level M, versions 1 to 40, the mask of the lowest penalty (rules 1, 2 and 4 of the standard). Follows the structure of Project Nayuki's QR Code generator (MIT)

final class MMO\oauth\helpers\QrCode
Espace de noms
MMO\oauth\helpers
echo QrCode::Svg(Totp::Uri($secret, 'Oviepro', 'ada@example.com'));

Constantes3

BLOCKS

const BLOCKS = […41 items]

ECC_PER_BLOCK

const ECC_PER_BLOCK = […41 items]

LEVEL_BITS

level M's two bits in the format information

const LEVEL_BITS = 0

Propriétés4

function

protected array $function = []
Type
array

modules

protected array $modules = []
Type
array

size

protected int $size
Type
int

version

protected int $version
Type
int

Méthodes19

alignmentPositions()

QrCode.php:237
protected function alignmentPositions(): array
retournearraythe centres of the alignment patterns, on each axis

drawCodewords($codewords)

QrCode.php:265
protected function drawCodewords(array $codewords): void
$codewordsarray
retournevoid

drawFormatBits($mask)

QrCode.php:246
protected function drawFormatBits(int $mask): void
$maskint
retournevoid

drawFunctionPatterns()

QrCode.php:196
protected function drawFunctionPatterns(): void
retournevoid

encode($data)

QrCode.php:108
protected function encode(array $data): array
$dataarraythe bytes of the text
retournearraythe data codewords: byte mode, its count, the bytes, the terminator and the padding

getModules()

QrCode.php:79
function getModules(): array
retournearrayarray<int, bool>> the modules, by row then column (true: dark), quiet zone excluded

GfMultiply($x, $y)

staticQrCode.php:180
protected static function GfMultiply(int $x, int $y): int
$xint
$yint
retourneint$x times $y in GF(2^8), modulo x^8 + x^4 + x^3 + x^2 + 1

interleave($data)

QrCode.php:123
protected function interleave(array $data): array
$dataarray
retournearraythe data split in blocks, each followed by its error correction, interleaved

penalty()

QrCode.php:303
protected function penalty(): int
retourneintthe penalty of the modules: runs of 5 or more (rule 1), 2x2 blocks (rule 2), the balance (rule 4)

RsDivisor($degree)

staticQrCode.php:150
protected static function RsDivisor(int $degree): array
$degreeint
retournearrayint> the generator polynomial of $degree, its leading term left out

RsRemainder($data, $divisor)

staticQrCode.php:169
protected static function RsRemainder(array $data, array $divisor): array
$dataarray
$divisorarray
retournearrayint> the error correction codewords of $data

Svg($text, $module, $title)

staticQrCode.php:62
static function Svg(string $text, int $module = 4, string $title = 'QR code'): string
$textstringwhat the code says
$module = 4intthe side of a module, in the svg's units
$title = 'QR code'string
retournestringan <svg> of the code with its quiet zone (4 modules), dark on white, scalable
QrCode::Svg('otpauth://totp/...', 4); // '<svg xmlns=... viewBox="0 0 ...">...</svg>'

toSvg($module, $title)

QrCode.php:66
function toSvg(int $module = 4, string $title = 'QR code'): string
$module = 4int
$title = 'QR code'string
retournestring

__construct($text)

QrCode.php:30
function __construct(string $text)
$textstring
lèveif $text does not fit in a version 40