BaconQrProvider.php 769 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. /**
  3. * @package Grav\Plugin\Login
  4. *
  5. * @copyright Copyright (C) 2014 - 2021 RocketTheme, LLC. All rights reserved.
  6. * @license MIT License; see LICENSE file for details.
  7. */
  8. namespace Grav\Plugin\Login\TwoFactorAuth;
  9. use BaconQrCode\Renderer\Image\Png as BaconPng;
  10. use BaconQrCode\Writer as BaconWriter;
  11. use RobThree\Auth\Providers\Qr\IQRCodeProvider;
  12. class BaconQrProvider implements IQRCodeProvider
  13. {
  14. public function getMimeType()
  15. {
  16. return 'image/png';
  17. }
  18. public function getQRCodeImage($qrtext, $size = 256)
  19. {
  20. $renderer = new BaconPng();
  21. $renderer->setHeight($size);
  22. $renderer->setWidth($size);
  23. $writer = new BaconWriter($renderer);
  24. return $writer->writeString($qrtext);
  25. }
  26. }