Encoding.php 465 B

123456789101112131415161718192021222324
  1. <?php
  2. declare(strict_types=1);
  3. namespace Endroid\QrCode\Encoding;
  4. final class Encoding implements EncodingInterface
  5. {
  6. private string $value;
  7. public function __construct(string $value)
  8. {
  9. if (!in_array($value, mb_list_encodings())) {
  10. throw new \Exception(sprintf('Invalid encoding "%s"', $value));
  11. }
  12. $this->value = $value;
  13. }
  14. public function __toString(): string
  15. {
  16. return $this->value;
  17. }
  18. }