QRDataModeInterface.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /**
  3. * Interface QRDataModeInterface
  4. *
  5. * @created 01.12.2015
  6. * @author Smiley <smiley@chillerlan.net>
  7. * @copyright 2015 Smiley
  8. * @license MIT
  9. */
  10. namespace chillerlan\QRCode\Data;
  11. use chillerlan\QRCode\Common\BitBuffer;
  12. /**
  13. * Specifies the methods reqired for the data modules (Number, Alphanum, Byte and Kanji)
  14. */
  15. interface QRDataModeInterface{
  16. /**
  17. * the current data mode: Number, Alphanum, Kanji, Hanzi, Byte, ECI
  18. *
  19. * Note: do not call this constant from the interface, but rather from one of the child classes
  20. *
  21. * @var int
  22. * @see \chillerlan\QRCode\Common\Mode
  23. */
  24. public const DATAMODE = -1;
  25. /**
  26. * retruns the length in bits of the data string
  27. */
  28. public function getLengthInBits():int;
  29. /**
  30. * encoding conversion helper
  31. *
  32. * @throws \chillerlan\QRCode\Data\QRCodeDataException
  33. */
  34. public static function convertEncoding(string $string):string;
  35. /**
  36. * checks if the given string qualifies for the encoder module
  37. */
  38. public static function validateString(string $string):bool;
  39. /**
  40. * writes the actual data string to the BitBuffer, uses the given version to determine the length bits
  41. *
  42. * @see \chillerlan\QRCode\Data\QRData::writeBitBuffer()
  43. */
  44. public function write(BitBuffer $bitBuffer, int $versionNumber):static;
  45. /**
  46. * reads a segment from the BitBuffer and decodes in the current data mode
  47. */
  48. public static function decodeSegment(BitBuffer $bitBuffer, int $versionNumber):string;
  49. }