mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2024-12-27 07:00:29 +01:00
26 lines
669 B
PHP
26 lines
669 B
PHP
<?php
|
|
|
|
namespace Xentral\Components\Barcode;
|
|
|
|
use Xentral\Components\Barcode\Exception\InvalidArgumentException;
|
|
|
|
final class BarcodeFactory
|
|
{
|
|
/**
|
|
* @param string $codeText
|
|
* @param string $ecLevel Error correction level [L|M|Q|H]
|
|
*
|
|
* @return Qrcode
|
|
*/
|
|
public function createQrCode($codeText, $ecLevel = 'L')
|
|
{
|
|
$codeType = 'QRCODE,' . $ecLevel;
|
|
if (!in_array($codeType, Qrcode::$validTypes, true)) {
|
|
throw new InvalidArgumentException('Invalid error correction level: ' . $ecLevel);
|
|
}
|
|
$barcode2d = new TcpdfBarcode2d($codeType, $codeText);
|
|
|
|
return new Qrcode($barcode2d);
|
|
}
|
|
}
|