withIssuer(Base::APPLICATION_NAME)->withLabel($email); $barcode=new TCPDF2DBarcode($otp->getProvisioningUri(),'QRCODE,M'); $matrix=$barcode->getBarcodeArray(); $size=(int)$matrix['num_cols'];$height=(int)$matrix['num_rows']; if($size<1||$height!==$size)throw new RuntimeException('Cannot generate authenticator QR code.'); // A four-module white quiet zone keeps the image scannable on dark pages. $edge=$size+8;$path=''; for($y=0;$y<$size;$y++)for($x=0;$x<$size;$x++){ if($matrix['bcode'][$y][$x])$path.='M'.($x+4).' '.($y+4).'h1v1h-1z'; } $svg=''; return 'data:image/svg+xml;base64,'.base64_encode($svg); } }