@@ -28,10 +28,13 @@ class EndroidQrCodeProvider implements IQRCodeProvider
28
28
29
29
protected $ endroid5 = false ;
30
30
31
+ protected $ endroid6 = false ;
32
+
31
33
public function __construct ($ bgcolor = 'ffffff ' , $ color = '000000 ' , $ margin = 0 , $ errorcorrectionlevel = 'H ' )
32
34
{
33
- $ this ->endroid4 = method_exists (QrCode::class, 'create ' );
34
35
$ 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 ' );
35
38
36
39
$ this ->bgcolor = $ this ->handleColor ($ bgcolor );
37
40
$ this ->color = $ this ->handleColor ($ color );
@@ -56,14 +59,24 @@ public function getQRCodeImage(string $qrText, int $size): string
56
59
57
60
protected function qrCodeInstance (string $ qrText , int $ size ): QrCode
58
61
{
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
+
59
73
$ qrCode = new QrCode ($ qrText );
60
74
$ qrCode ->setSize ($ size );
61
75
62
76
$ qrCode ->setErrorCorrectionLevel ($ this ->errorcorrectionlevel );
63
77
$ qrCode ->setMargin ($ this ->margin );
64
78
$ qrCode ->setBackgroundColor ($ this ->bgcolor );
65
79
$ qrCode ->setForegroundColor ($ this ->color );
66
-
67
80
return $ qrCode ;
68
81
}
69
82
0 commit comments