⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.19
Server IP:
178.33.27.10
Server:
Linux cpanel.dev-unit.com 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64
Server Software:
Apache/2.4.57 (Unix) OpenSSL/1.0.2k-fips
PHP Version:
8.2.11
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
home
/
id
/
erp.dev-unit.com
/
vendor
/
salla
/
zatca
/
src
/
View File Name :
GenerateQrCode.php
<?php namespace Salla\ZATCA; use chillerlan\QRCode\QRCode; use InvalidArgumentException; use chillerlan\QRCode\QROptions; class GenerateQrCode { /** * @var Tag|Tag[] $data The data or list of tags */ protected $data = []; /** * @param Tag|Tag[] $data The data or list of tags * * @throws InvalidArgumentException If the TLV data structure * contains other data than arrays and Tag instances. */ private function __construct($data) { $this->data = array_filter($data, function ($tag) { return $tag instanceof Tag; }); if (\count($this->data) === 0) { throw new InvalidArgumentException('malformed data structure'); } } /** * Initial the generator from list of tags. * * @param Tag[] $data The list of tags * * @return GenerateQrCode */ public static function fromArray(array $data): GenerateQrCode { return new self($data); } /** * Encodes an TLV data structure. * * @return string Returns a string representing the encoded TLV data structure. */ public function toTLV(): string { return implode('', array_map(function ($tag) { return (string) $tag; }, $this->data)); } /** * Encodes an TLV as base64 * * @return string Returns the TLV as base64 encode. */ public function toBase64(): string { return base64_encode($this->toTLV()); } /** * Render the QR code as base64 data image. * * @param array $options The list of options for QROption (https://github.com/chillerlan/php-qrcode) * @param string|null $file File string represent file path,name and extension * * @return string */ public function render(array $options = [], string $file = null): string { $options = new QROptions($options); return (new QRCode($options))->render($this->toBase64(), $file); } }