@@ -79,15 +79,7 @@ private function handleColor(string $color): Color|array
79
79
80
80
private function handleErrorCorrectionLevel (string $ level ): ErrorCorrectionLevelInterface |ErrorCorrectionLevel
81
81
{
82
- if ($ this ->endroid4 ) {
83
- return match ($ level ) {
84
- 'L ' => new ErrorCorrectionLevelLow (),
85
- 'M ' => new ErrorCorrectionLevelMedium (),
86
- 'Q ' => new ErrorCorrectionLevelQuartile (),
87
- default => new ErrorCorrectionLevelHigh (),
88
- };
89
- }
90
-
82
+ // First check for version 5 (using consts)
91
83
if ($ this ->endroid5 ) {
92
84
return match ($ level ) {
93
85
'L ' => ErrorCorrectionLevel::Low,
@@ -97,7 +89,17 @@ private function handleErrorCorrectionLevel(string $level): ErrorCorrectionLevel
97
89
};
98
90
}
99
91
100
- // Assuming this is for version EndroidQR < 4
92
+ // If not check for version 4 (using classes)
93
+ if ($ this ->endroid4 ) {
94
+ return match ($ level ) {
95
+ 'L ' => new ErrorCorrectionLevelLow (),
96
+ 'M ' => new ErrorCorrectionLevelMedium (),
97
+ 'Q ' => new ErrorCorrectionLevelQuartile (),
98
+ default => new ErrorCorrectionLevelHigh (),
99
+ };
100
+ }
101
+
102
+ // Any other version will be using strings
101
103
return match ($ level ) {
102
104
'L ' => ErrorCorrectionLevel::LOW (),
103
105
'M ' => ErrorCorrectionLevel::MEDIUM (),
0 commit comments