@@ -28,10 +28,13 @@ class EndroidQrCodeProvider implements IQRCodeProvider
2828
2929 protected $ endroid5 = false ;
3030
31+ protected $ endroid6 = false ;
32+
3133 public function __construct ($ bgcolor = 'ffffff ' , $ color = '000000 ' , $ margin = 0 , $ errorcorrectionlevel = 'H ' )
3234 {
33- $ this ->endroid4 = method_exists (QrCode::class, 'create ' );
3435 $ this ->endroid5 = enum_exists (ErrorCorrectionLevel::class);
36+ $ this ->endroid6 = $ this ->endroid5 && !method_exists (QrCode::class, 'setSize ' );
37+ $ this ->endroid4 = $ this ->endroid6 || method_exists (QrCode::class, 'create ' );
3538
3639 $ this ->bgcolor = $ this ->handleColor ($ bgcolor );
3740 $ this ->color = $ this ->handleColor ($ color );
@@ -56,14 +59,24 @@ public function getQRCodeImage(string $qrText, int $size): string
5659
5760 protected function qrCodeInstance (string $ qrText , int $ size ): QrCode
5861 {
62+ if ($ this ->endroid6 ) {
63+ return new QrCode (
64+ data: $ qrText ,
65+ errorCorrectionLevel: $ this ->errorcorrectionlevel ,
66+ size: $ size ,
67+ margin: $ this ->margin ,
68+ foregroundColor: $ this ->color ,
69+ backgroundColor: $ this ->bgcolor
70+ );
71+ }
72+
5973 $ qrCode = new QrCode ($ qrText );
6074 $ qrCode ->setSize ($ size );
6175
6276 $ qrCode ->setErrorCorrectionLevel ($ this ->errorcorrectionlevel );
6377 $ qrCode ->setMargin ($ this ->margin );
6478 $ qrCode ->setBackgroundColor ($ this ->bgcolor );
6579 $ qrCode ->setForegroundColor ($ this ->color );
66-
6780 return $ qrCode ;
6881 }
6982
0 commit comments