Used lowercase values when trying to match the QR code error level

This commit is contained in:
Alejandro Celaya 2021-07-13 13:55:00 +02:00
parent 01e06f0503
commit 67c7e503d9

View file

@ -16,7 +16,6 @@ use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\ServerRequestInterface as Request; use Psr\Http\Message\ServerRequestInterface as Request;
use function strtolower; use function strtolower;
use function strtoupper;
use function trim; use function trim;
final class QrCodeParams final class QrCodeParams
@ -82,12 +81,12 @@ final class QrCodeParams
private static function resolveErrorCorrection(array $query): ErrorCorrectionLevelInterface private static function resolveErrorCorrection(array $query): ErrorCorrectionLevelInterface
{ {
$errorCorrectionLevel = strtoupper(trim($query['errorCorrection'] ?? '')); $errorCorrectionLevel = strtolower(trim($query['errorCorrection'] ?? 'l'));
return match ($errorCorrectionLevel) { return match ($errorCorrectionLevel) {
'H' => new ErrorCorrectionLevelHigh(), 'h' => new ErrorCorrectionLevelHigh(),
'Q' => new ErrorCorrectionLevelQuartile(), 'q' => new ErrorCorrectionLevelQuartile(),
'M' => new ErrorCorrectionLevelMedium(), 'm' => new ErrorCorrectionLevelMedium(),
default => new ErrorCorrectionLevelLow(), // 'L' default => new ErrorCorrectionLevelLow(), // 'l'
}; };
} }