mirror of
https://github.com/RobThree/TwoFactorAuth.git
synced 2026-08-31 04:27:05 +00:00
@@ -10,6 +10,8 @@ class EndroidQrCodeProvider implements IQRCodeProvider
|
||||
public $color;
|
||||
public $margin;
|
||||
public $errorcorrectionlevel;
|
||||
protected $logoPath;
|
||||
protected $logoSize;
|
||||
|
||||
public function __construct($bgcolor = 'ffffff', $color = '000000', $margin = 0, $errorcorrectionlevel = 'H')
|
||||
{
|
||||
@@ -19,6 +21,17 @@ class EndroidQrCodeProvider implements IQRCodeProvider
|
||||
$this->errorcorrectionlevel = $this->handleErrorCorrectionLevel($errorcorrectionlevel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an image to the middle of the QR Code.
|
||||
* @param string $path Path to an image file
|
||||
* @param array|int $size Just the width, or [width, height]
|
||||
*/
|
||||
public function setLogo($path, $size = null)
|
||||
{
|
||||
$this->logoPath = $path;
|
||||
$this->logoSize = (array)$size;
|
||||
}
|
||||
|
||||
public function getMimeType()
|
||||
{
|
||||
return 'image/png';
|
||||
@@ -34,6 +47,13 @@ class EndroidQrCodeProvider implements IQRCodeProvider
|
||||
$qrCode->setBackgroundColor($this->bgcolor);
|
||||
$qrCode->setForegroundColor($this->color);
|
||||
|
||||
if ($this->logoPath) {
|
||||
$qrCode->setLogoPath($this->logoPath);
|
||||
if ($this->logoSize) {
|
||||
$qrCode->setLogoSize($this->logoSize[0], $this->logoSize[1]);
|
||||
}
|
||||
}
|
||||
|
||||
return $qrCode->writeString();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user