From 30248a8fb520696fe3128fe1d366aeb86296072f Mon Sep 17 00:00:00 2001 From: Nicolas CARPi Date: Wed, 22 Feb 2023 18:08:19 +0100 Subject: [PATCH] address remarks made by MasterOdin --- README.md | 2 +- lib/Providers/Qr/BaconQrCodeProvider.php | 4 ---- testsDependency/BaconQRCodeTest.php | 16 ++++------------ 3 files changed, 5 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index c048672..23800ce 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ PHP library for [two-factor (or multi-factor) authentication](http://en.wikipedi ## Requirements -* Requires PHP version >8.1 +* Requires PHP version >=8.1 * [cURL](http://php.net/manual/en/book.curl.php) when using the provided `QRServerProvider` (default), `ImageChartsQRCodeProvider` or `QRicketProvider` but you can also provide your own QR-code provider. * [random_bytes()](http://php.net/manual/en/function.random-bytes.php), [OpenSSL](http://php.net/manual/en/book.openssl.php) or [Hash](http://php.net/manual/en/book.hash.php) depending on which built-in RNG you use (TwoFactorAuth will try to 'autodetect' and use the best available); however: feel free to provide your own (CS)RNG. diff --git a/lib/Providers/Qr/BaconQrCodeProvider.php b/lib/Providers/Qr/BaconQrCodeProvider.php index 3b192cb..2660e71 100644 --- a/lib/Providers/Qr/BaconQrCodeProvider.php +++ b/lib/Providers/Qr/BaconQrCodeProvider.php @@ -28,10 +28,6 @@ class BaconQrCodeProvider implements IQRCodeProvider private string|array $foregroundColour = '#000000', private string $format = 'png', ) { - if (!class_exists(ImagickImageBackEnd::class)) { - throw new RuntimeException('Make sure you are using version 2 of Bacon QR Code'); - } - $this->backgroundColour = $this->handleColour($this->backgroundColour); $this->foregroundColour = $this->handleColour($this->foregroundColour); $this->format = strtolower($this->format); diff --git a/testsDependency/BaconQRCodeTest.php b/testsDependency/BaconQRCodeTest.php index 3c79838..4c224c9 100644 --- a/testsDependency/BaconQRCodeTest.php +++ b/testsDependency/BaconQRCodeTest.php @@ -4,7 +4,6 @@ declare(strict_types=1); namespace TestsDependency; -use BaconQrCode\Renderer\Image\ImagickImageBackEnd; use PHPUnit\Framework\TestCase; use RobThree\Auth\Algorithm; use RobThree\Auth\Providers\Qr\BaconQrCodeProvider; @@ -18,19 +17,12 @@ class BaconQRCodeTest extends TestCase public function testDependency(): void { - // php < 7.1 will install an older Bacon QR Code - if (!class_exists(ImagickImageBackEnd::class)) { - $this->expectException(RuntimeException::class); + $qr = new BaconQrCodeProvider(1, '#000', '#FFF', 'svg'); - $qr = new BaconQrCodeProvider(1, '#000', '#FFF', 'svg'); - } else { - $qr = new BaconQrCodeProvider(1, '#000', '#FFF', 'svg'); + $tfa = new TwoFactorAuth('Test&Issuer', 6, 30, Algorithm::Sha1, $qr); - $tfa = new TwoFactorAuth('Test&Issuer', 6, 30, Algorithm::Sha1, $qr); - - $data = $this->DecodeDataUri($tfa->getQRCodeImageAsDataUri('Test&Label', 'VMR466AB62ZBOKHE')); - $this->assertEquals('image/svg+xml', $data['mimetype']); - } + $data = $this->DecodeDataUri($tfa->getQRCodeImageAsDataUri('Test&Label', 'VMR466AB62ZBOKHE')); + $this->assertEquals('image/svg+xml', $data['mimetype']); } public function testBadTextColour(): void