custom.php 846 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. require_once '../vendor/autoload.php';
  3. use chillerlan\QRCode\QRCode;
  4. use chillerlan\QRCode\QROptions;
  5. use chillerlan\QRCode\Output\QROutputBase;
  6. use chillerlan\QRCode\Output\QROutputInterface;
  7. /**
  8. * Class MyCustomOutput
  9. */
  10. class MyCustomOutput extends QROutputBase implements QROutputInterface{
  11. /**
  12. * @return mixed
  13. * @throws \chillerlan\QRCode\Output\QRCodeOutputException
  14. */
  15. public function dump(){
  16. $output = '';
  17. for($row = 0; $row < $this->pixelCount; $row++){
  18. for($col = 0; $col < $this->pixelCount; $col++){
  19. $output .= (string)(int)$this->matrix[$row][$col];
  20. }
  21. }
  22. return $output;
  23. }
  24. }
  25. $starttime = microtime(true);
  26. echo (new QRCode('otpauth://totp/test?secret=B3JX4VCVJDVNXNZ5&issuer=chillerlan.net', new MyCustomOutput))->output();
  27. echo PHP_EOL.'QRCode: '.round((microtime(true)-$starttime), 5);