QROutputInterface.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <?php
  2. /**
  3. * Interface QROutputInterface,
  4. *
  5. * @created 02.12.2015
  6. * @author Smiley <smiley@chillerlan.net>
  7. * @copyright 2015 Smiley
  8. * @license MIT
  9. */
  10. namespace chillerlan\QRCode\Output;
  11. use chillerlan\QRCode\Data\QRMatrix;
  12. /**
  13. * Converts the data matrix into readable output
  14. */
  15. interface QROutputInterface{
  16. /**
  17. * Map of built-in output class FQN
  18. *
  19. * @var string[]
  20. * @see https://github.com/chillerlan/php-qrcode/issues/223
  21. */
  22. public const MODES = [
  23. QREps::class,
  24. QRFpdf::class,
  25. QRGdImageAVIF::class,
  26. QRGdImageBMP::class,
  27. QRGdImageGIF::class,
  28. QRGdImageJPEG::class,
  29. QRGdImagePNG::class,
  30. QRGdImageWEBP::class,
  31. QRImagick::class,
  32. QRInterventionImage::class,
  33. QRMarkupHTML::class,
  34. QRMarkupSVG::class,
  35. QRMarkupXML::class,
  36. QRStringJSON::class,
  37. QRStringText::class,
  38. ];
  39. /**
  40. * Map of module type => default value
  41. *
  42. * @var bool[]
  43. */
  44. public const DEFAULT_MODULE_VALUES = [
  45. // light
  46. QRMatrix::M_NULL => false,
  47. QRMatrix::M_DARKMODULE_LIGHT => false,
  48. QRMatrix::M_DATA => false,
  49. QRMatrix::M_FINDER => false,
  50. QRMatrix::M_SEPARATOR => false,
  51. QRMatrix::M_ALIGNMENT => false,
  52. QRMatrix::M_TIMING => false,
  53. QRMatrix::M_FORMAT => false,
  54. QRMatrix::M_VERSION => false,
  55. QRMatrix::M_QUIETZONE => false,
  56. QRMatrix::M_LOGO => false,
  57. QRMatrix::M_FINDER_DOT_LIGHT => false,
  58. // dark
  59. QRMatrix::M_DARKMODULE => true,
  60. QRMatrix::M_DATA_DARK => true,
  61. QRMatrix::M_FINDER_DARK => true,
  62. QRMatrix::M_SEPARATOR_DARK => true,
  63. QRMatrix::M_ALIGNMENT_DARK => true,
  64. QRMatrix::M_TIMING_DARK => true,
  65. QRMatrix::M_FORMAT_DARK => true,
  66. QRMatrix::M_VERSION_DARK => true,
  67. QRMatrix::M_QUIETZONE_DARK => true,
  68. QRMatrix::M_LOGO_DARK => true,
  69. QRMatrix::M_FINDER_DOT => true,
  70. ];
  71. /**
  72. * Map of module type => readable name (for CSS etc.)
  73. *
  74. * @var string[]
  75. */
  76. public const LAYERNAMES = [
  77. // light
  78. QRMatrix::M_NULL => 'null',
  79. QRMatrix::M_DARKMODULE_LIGHT => 'darkmodule-light',
  80. QRMatrix::M_DATA => 'data',
  81. QRMatrix::M_FINDER => 'finder',
  82. QRMatrix::M_SEPARATOR => 'separator',
  83. QRMatrix::M_ALIGNMENT => 'alignment',
  84. QRMatrix::M_TIMING => 'timing',
  85. QRMatrix::M_FORMAT => 'format',
  86. QRMatrix::M_VERSION => 'version',
  87. QRMatrix::M_QUIETZONE => 'quietzone',
  88. QRMatrix::M_LOGO => 'logo',
  89. QRMatrix::M_FINDER_DOT_LIGHT => 'finder-dot-light',
  90. // dark
  91. QRMatrix::M_DARKMODULE => 'darkmodule',
  92. QRMatrix::M_DATA_DARK => 'data-dark',
  93. QRMatrix::M_FINDER_DARK => 'finder-dark',
  94. QRMatrix::M_SEPARATOR_DARK => 'separator-dark',
  95. QRMatrix::M_ALIGNMENT_DARK => 'alignment-dark',
  96. QRMatrix::M_TIMING_DARK => 'timing-dark',
  97. QRMatrix::M_FORMAT_DARK => 'format-dark',
  98. QRMatrix::M_VERSION_DARK => 'version-dark',
  99. QRMatrix::M_QUIETZONE_DARK => 'quietzone-dark',
  100. QRMatrix::M_LOGO_DARK => 'logo-dark',
  101. QRMatrix::M_FINDER_DOT => 'finder-dot',
  102. ];
  103. /**
  104. * Note: do not call this constant from the interface, but rather from one of the child classes
  105. *
  106. * @var string
  107. * @see \chillerlan\QRCode\Output\QROutputAbstract::toBase64DataURI()
  108. */
  109. public const MIME_TYPE = '';
  110. /**
  111. * Determines whether the given value is valid
  112. */
  113. public static function moduleValueIsValid(mixed $value):bool;
  114. /**
  115. * Generates the output, optionally dumps it to a file, and returns it
  116. *
  117. * please note that the value of QROptions::$cachefile is already evaluated at this point.
  118. * if the output module is invoked manually, it has no effect at all.
  119. * you need to supply the $file parameter here in that case (or handle the option value in your custom output module).
  120. *
  121. * @see \chillerlan\QRCode\QRCode::renderMatrix()
  122. */
  123. public function dump(string $file = null):mixed;
  124. }