Byte.php 680 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * Class Byte
  4. *
  5. * @filesource Byte.php
  6. * @created 25.11.2015
  7. * @package chillerlan\QRCode\Data
  8. * @author Smiley <smiley@chillerlan.net>
  9. * @copyright 2015 Smiley
  10. * @license MIT
  11. */
  12. namespace chillerlan\QRCode\Data;
  13. use chillerlan\QRCode\QRCode;
  14. /**
  15. * Byte mode, ISO-8859-1 or UTF-8
  16. */
  17. class Byte extends QRDataAbstract{
  18. /**
  19. * @inheritdoc
  20. */
  21. protected $datamode = QRCode::DATA_BYTE;
  22. /**
  23. * @inheritdoc
  24. */
  25. protected $lengthBits = [8, 16, 16];
  26. /**
  27. * @inheritdoc
  28. */
  29. protected function write(string $data):void{
  30. $i = 0;
  31. while($i < $this->strlen){
  32. $this->bitBuffer->put(\ord($data[$i]), 8);
  33. $i++;
  34. }
  35. }
  36. }