Skip to content

Commit 4b6b060

Browse files
committed
Fixed check ordering
1 parent 126afe4 commit 4b6b060

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

lib/Providers/Qr/EndroidQrCodeProvider.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,7 @@ private function handleColor(string $color): Color|array
7979

8080
private function handleErrorCorrectionLevel(string $level): ErrorCorrectionLevelInterface|ErrorCorrectionLevel
8181
{
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)
9183
if ($this->endroid5) {
9284
return match ($level) {
9385
'L' => ErrorCorrectionLevel::Low,
@@ -97,7 +89,17 @@ private function handleErrorCorrectionLevel(string $level): ErrorCorrectionLevel
9789
};
9890
}
9991

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
101103
return match ($level) {
102104
'L' => ErrorCorrectionLevel::LOW(),
103105
'M' => ErrorCorrectionLevel::MEDIUM(),

0 commit comments

Comments
 (0)