Documentations › mmo.oauth › php › helpers QrCode MMO\oauth\helpers · 1 symbole · générée le 30 Nov 2026
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\helpersecho QrCode::Svg(Totp::Uri($secret, 'Oviepro', 'ada@example.com'));
Constantes3 const BLOCKS = […41 items] const ECC_PER_BLOCK = […41 items] level M's two bits in the format information
const LEVEL_BITS = 0 Propriétés4 protected array $function = [] Type array protected array $modules = [] Type array protected int $size Type int protected int $version Type int Méthodes19 protected function alignmentPositions(): array retourne array the centres of the alignment patterns, on each axis
protected function applyMask(int $mask): void protected function dataCodewords(): int protected function drawCodewords(array $codewords): void protected function drawFormatBits(int $mask): void protected function drawFunctionPatterns(): void protected function encode(array $data): array $data array the bytes of the text retourne array the data codewords: byte mode, its count, the bytes, the terminator and the padding
function getModules(): array retourne array array<int, bool>> the modules, by row then column (true: dark), quiet zone excluded
function getVersion(): int protected static function GfMultiply(int $x, int $y): int $x int $y int retourne int $x times $y in GF(2^8), modulo x^8 + x^4 + x^3 + x^2 + 1
protected function interleave(array $data): array $data array retourne array the data split in blocks, each followed by its error correction, interleaved
protected function penalty(): int retourne int the penalty of the modules: runs of 5 or more (rule 1), 2x2 blocks (rule 2), the balance (rule 4)
protected function rawModules(): int protected static function RsDivisor(int $degree): array $degree int retourne array int> the generator polynomial of $degree, its leading term left out
protected static function RsRemainder(array $data, array $divisor): array $data array $divisor array retourne array int> the error correction codewords of $data
protected function setFunction(int $x, int $y, bool $dark): void static function Svg(string $text, int $module = 4, string $title = 'QR code'): string $text string what the code says $module = 4 int the side of a module, in the svg's units $title = 'QR code' string retourne string an <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>'
function toSvg(int $module = 4, string $title = 'QR code'): string function __construct(string $text) $text string lève if $text does not fit in a version 40