QROutputInterface.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. /** @var string */
  17. public const MARKUP_HTML = 'html';
  18. /** @var string */
  19. public const MARKUP_SVG = 'svg';
  20. /** @var string */
  21. public const GDIMAGE_PNG = 'png';
  22. /** @var string */
  23. public const GDIMAGE_JPG = 'jpg';
  24. /** @var string */
  25. public const GDIMAGE_GIF = 'gif';
  26. /** @var string */
  27. public const STRING_JSON = 'json';
  28. /** @var string */
  29. public const STRING_TEXT = 'text';
  30. /** @var string */
  31. public const IMAGICK = 'imagick';
  32. /** @var string */
  33. public const FPDF = 'fpdf';
  34. /** @var string */
  35. public const EPS = 'eps';
  36. /** @var string */
  37. public const CUSTOM = 'custom';
  38. /**
  39. * Map of built-in output modes => class FQN
  40. *
  41. * @var string[]
  42. */
  43. public const MODES = [
  44. self::MARKUP_SVG => QRMarkupSVG::class,
  45. self::MARKUP_HTML => QRMarkupHTML::class,
  46. self::GDIMAGE_PNG => QRGdImage::class,
  47. self::GDIMAGE_GIF => QRGdImage::class,
  48. self::GDIMAGE_JPG => QRGdImage::class,
  49. self::STRING_JSON => QRString::class,
  50. self::STRING_TEXT => QRString::class,
  51. self::IMAGICK => QRImagick::class,
  52. self::FPDF => QRFpdf::class,
  53. self::EPS => QREps::class,
  54. ];
  55. /**
  56. * Map of module type => default value
  57. *
  58. * @var bool[]
  59. */
  60. public const DEFAULT_MODULE_VALUES = [
  61. // light
  62. QRMatrix::M_NULL => false,
  63. QRMatrix::M_DATA => false,
  64. QRMatrix::M_FINDER => false,
  65. QRMatrix::M_SEPARATOR => false,
  66. QRMatrix::M_ALIGNMENT => false,
  67. QRMatrix::M_TIMING => false,
  68. QRMatrix::M_FORMAT => false,
  69. QRMatrix::M_VERSION => false,
  70. QRMatrix::M_QUIETZONE => false,
  71. QRMatrix::M_LOGO => false,
  72. QRMatrix::M_TEST => false,
  73. // dark
  74. QRMatrix::M_DARKMODULE => true,
  75. QRMatrix::M_DATA_DARK => true,
  76. QRMatrix::M_FINDER_DARK => true,
  77. QRMatrix::M_SEPARATOR_DARK => true,
  78. QRMatrix::M_ALIGNMENT_DARK => true,
  79. QRMatrix::M_TIMING_DARK => true,
  80. QRMatrix::M_FORMAT_DARK => true,
  81. QRMatrix::M_VERSION_DARK => true,
  82. QRMatrix::M_QUIETZONE_DARK => true,
  83. QRMatrix::M_LOGO_DARK => true,
  84. QRMatrix::M_FINDER_DOT => true,
  85. QRMatrix::M_TEST_DARK => true,
  86. ];
  87. /**
  88. * Map of module type => readable name (for CSS etc.)
  89. *
  90. * @var string[]
  91. */
  92. public const LAYERNAMES = [
  93. // light
  94. QRMatrix::M_NULL => 'null',
  95. QRMatrix::M_DATA => 'data',
  96. QRMatrix::M_FINDER => 'finder',
  97. QRMatrix::M_SEPARATOR => 'separator',
  98. QRMatrix::M_ALIGNMENT => 'alignment',
  99. QRMatrix::M_TIMING => 'timing',
  100. QRMatrix::M_FORMAT => 'format',
  101. QRMatrix::M_VERSION => 'version',
  102. QRMatrix::M_QUIETZONE => 'quietzone',
  103. QRMatrix::M_LOGO => 'logo',
  104. QRMatrix::M_TEST => 'test',
  105. // dark
  106. QRMatrix::M_DARKMODULE => 'darkmodule',
  107. QRMatrix::M_DATA_DARK => 'data-dark',
  108. QRMatrix::M_FINDER_DARK => 'finder-dark',
  109. QRMatrix::M_SEPARATOR_DARK => 'separator-dark',
  110. QRMatrix::M_ALIGNMENT_DARK => 'alignment-dark',
  111. QRMatrix::M_TIMING_DARK => 'timing-dark',
  112. QRMatrix::M_FORMAT_DARK => 'format-dark',
  113. QRMatrix::M_VERSION_DARK => 'version-dark',
  114. QRMatrix::M_QUIETZONE_DARK => 'quietzone-dark',
  115. QRMatrix::M_LOGO_DARK => 'logo-dark',
  116. QRMatrix::M_FINDER_DOT => 'finder-dot',
  117. QRMatrix::M_TEST_DARK => 'test-dark',
  118. ];
  119. /**
  120. * Determines whether the given value is valid
  121. *
  122. * @param mixed $value
  123. */
  124. public static function moduleValueIsValid($value):bool;
  125. /**
  126. * generates the output, optionally dumps it to a file, and returns it
  127. *
  128. * please note that the value of QROptions::$cachefile is already evaluated at this point.
  129. * if the output module is invoked manually, it has no effect at all.
  130. * you need to supply the $file parameter here in that case (or handle the option value in your custom output module).
  131. *
  132. * @see \chillerlan\QRCode\QRCode::renderMatrix()
  133. *
  134. * @return mixed
  135. */
  136. public function dump(string $file = null);
  137. }