ErrorCorrectionLevel.php 992 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4. * (c) Jeroen van den Enden <info@endroid.nl>
  5. *
  6. * This source file is subject to the MIT license that is bundled
  7. * with this source code in the file LICENSE.
  8. */
  9. namespace Endroid\QrCode;
  10. use BaconQrCode\Common\ErrorCorrectionLevel as BaconErrorCorrectionLevel;
  11. use MyCLabs\Enum\Enum;
  12. /**
  13. * @method static ErrorCorrectionLevel LOW()
  14. * @method static ErrorCorrectionLevel MEDIUM()
  15. * @method static ErrorCorrectionLevel QUARTILE()
  16. * @method static ErrorCorrectionLevel HIGH()
  17. *
  18. * @extends Enum<string>
  19. * @psalm-immutable
  20. */
  21. class ErrorCorrectionLevel extends Enum
  22. {
  23. const LOW = 'low';
  24. const MEDIUM = 'medium';
  25. const QUARTILE = 'quartile';
  26. const HIGH = 'high';
  27. /**
  28. * @psalm-suppress ImpureMethodCall
  29. */
  30. public function toBaconErrorCorrectionLevel(): BaconErrorCorrectionLevel
  31. {
  32. $name = strtoupper(substr($this->getValue(), 0, 1));
  33. return BaconErrorCorrectionLevel::valueOf($name);
  34. }
  35. }