mirror of
https://github.com/RobThree/TwoFactorAuth.git
synced 2026-08-31 04:27:05 +00:00
add support for endroid/qr-code version 6 (#140)
* add support for endroid/qr-code version 6 * add endroid v6 to github workflows * remove negative conditional (endroid-related) --------- Co-authored-by: Clifford Vickrey <cvickrey@insuranceautomationgroup.com>
This commit is contained in:
@@ -11,7 +11,7 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
php-version: ['8.2', '8.3']
|
||||
endroid-version: ["^3","^4","^5"]
|
||||
endroid-version: ["^3","^4","^5","^6"]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
@@ -28,10 +28,13 @@ class EndroidQrCodeProvider implements IQRCodeProvider
|
||||
|
||||
protected $endroid5 = false;
|
||||
|
||||
protected $endroid6 = false;
|
||||
|
||||
public function __construct($bgcolor = 'ffffff', $color = '000000', $margin = 0, $errorcorrectionlevel = 'H')
|
||||
{
|
||||
$this->endroid4 = method_exists(QrCode::class, 'create');
|
||||
$this->endroid5 = enum_exists(ErrorCorrectionLevel::class);
|
||||
$this->endroid6 = $this->endroid5 && !method_exists(QrCode::class, 'setSize');
|
||||
$this->endroid4 = $this->endroid6 || method_exists(QrCode::class, 'create');
|
||||
|
||||
$this->bgcolor = $this->handleColor($bgcolor);
|
||||
$this->color = $this->handleColor($color);
|
||||
@@ -56,6 +59,17 @@ class EndroidQrCodeProvider implements IQRCodeProvider
|
||||
|
||||
protected function qrCodeInstance(string $qrText, int $size): QrCode
|
||||
{
|
||||
if ($this->endroid6) {
|
||||
return new QrCode(
|
||||
data: $qrText,
|
||||
errorCorrectionLevel: $this->errorcorrectionlevel,
|
||||
size: $size,
|
||||
margin: $this->margin,
|
||||
foregroundColor: $this->color,
|
||||
backgroundColor: $this->bgcolor
|
||||
);
|
||||
}
|
||||
|
||||
$qrCode = new QrCode($qrText);
|
||||
$qrCode->setSize($size);
|
||||
|
||||
@@ -63,7 +77,6 @@ class EndroidQrCodeProvider implements IQRCodeProvider
|
||||
$qrCode->setMargin($this->margin);
|
||||
$qrCode->setBackgroundColor($this->bgcolor);
|
||||
$qrCode->setForegroundColor($this->color);
|
||||
|
||||
return $qrCode;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user