Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame^] | 1 | <?php |
| 2 | |
| 3 | namespace RobThree\Auth\Providers\Qr; |
| 4 | |
| 5 | // http://qrickit.com/qrickit_apps/qrickit_api.php |
| 6 | class QRicketProvider extends BaseHTTPQRCodeProvider |
| 7 | { |
| 8 | public $errorcorrectionlevel; |
| 9 | public $margin; |
| 10 | public $qzone; |
| 11 | public $bgcolor; |
| 12 | public $color; |
| 13 | public $format; |
| 14 | |
| 15 | function __construct($errorcorrectionlevel = 'L', $bgcolor = 'ffffff', $color = '000000', $format = 'p') |
| 16 | { |
| 17 | $this->verifyssl = false; |
| 18 | |
| 19 | $this->errorcorrectionlevel = $errorcorrectionlevel; |
| 20 | $this->bgcolor = $bgcolor; |
| 21 | $this->color = $color; |
| 22 | $this->format = $format; |
| 23 | } |
| 24 | |
| 25 | public function getMimeType() |
| 26 | { |
| 27 | switch (strtolower($this->format)) |
| 28 | { |
| 29 | case 'p': |
| 30 | return 'image/png'; |
| 31 | case 'g': |
| 32 | return 'image/gif'; |
| 33 | case 'j': |
| 34 | return 'image/jpeg'; |
| 35 | } |
| 36 | throw new \QRException(sprintf('Unknown MIME-type: %s', $this->format)); |
| 37 | } |
| 38 | |
| 39 | public function getQRCodeImage($qrtext, $size) |
| 40 | { |
| 41 | return $this->getContent($this->getUrl($qrtext, $size)); |
| 42 | } |
| 43 | |
| 44 | public function getUrl($qrtext, $size) |
| 45 | { |
| 46 | return 'http://qrickit.com/api/qr' |
| 47 | . '?qrsize=' . $size |
| 48 | . '&e=' . strtolower($this->errorcorrectionlevel) |
| 49 | . '&bgdcolor=' . $this->bgcolor |
| 50 | . '&fgdcolor=' . $this->color |
| 51 | . '&t=' . strtolower($this->format) |
| 52 | . '&d=' . rawurlencode($qrtext); |
| 53 | } |
| 54 | } |