QRStringJSON.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /**
  3. * Class QRStringJSON
  4. *
  5. * @created 25.10.2023
  6. * @author smiley <smiley@chillerlan.net>
  7. * @copyright 2023 smiley
  8. * @license MIT
  9. *
  10. * @noinspection PhpComposerExtensionStubsInspection
  11. */
  12. namespace chillerlan\QRCode\Output;
  13. use function json_encode;
  14. /**
  15. *
  16. */
  17. class QRStringJSON extends QROutputAbstract{
  18. public const MIME_TYPE = 'application/json';
  19. /**
  20. * @inheritDoc
  21. * @throws \JsonException
  22. */
  23. public function dump(?string $file = null):string{
  24. $matrix = $this->matrix->getMatrix($this->options->jsonAsBooleans);
  25. $data = json_encode($matrix, $this->options->jsonFlags);
  26. $this->saveToFile($data, $file);
  27. return $data;
  28. }
  29. /**
  30. * unused - required by interface
  31. *
  32. * @inheritDoc
  33. * @codeCoverageIgnore
  34. */
  35. protected function prepareModuleValue($value):string{
  36. return '';
  37. }
  38. /**
  39. * unused - required by interface
  40. *
  41. * @inheritDoc
  42. * @codeCoverageIgnore
  43. */
  44. protected function getDefaultModuleValue(bool $isDark):string{
  45. return '';
  46. }
  47. /**
  48. * unused - required by interface
  49. *
  50. * @inheritDoc
  51. * @codeCoverageIgnore
  52. */
  53. public static function moduleValueIsValid($value):bool{
  54. return true;
  55. }
  56. }