verifyssl = $verifyssl; $this->errorcorrectionlevel = $errorcorrectionlevel; $this->margin = $margin; $this->qzone = $qzone; $this->bgcolor = $bgcolor; $this->color = $color; $this->format = $format; } /** * {@inheritdoc} */ public function getMimeType() { switch (strtolower($this->format)) { case 'png': return 'image/png'; case 'gif': return 'image/gif'; case 'jpg': case 'jpeg': return 'image/jpeg'; case 'svg': return 'image/svg+xml'; case 'eps': return 'application/postscript'; } throw new QRException(sprintf('Unknown MIME-type: %s', $this->format)); } /** * {@inheritdoc} */ public function getQRCodeImage($qrtext, $size) { return $this->getContent($this->getUrl($qrtext, $size)); } /** * @param string $value * * @return string */ private function decodeColor($value) { return vsprintf('%d-%d-%d', sscanf($value, "%02x%02x%02x")); } /** * @param string $qrtext the value to encode in the QR code * @param int|string $size the desired size of the QR code * * @return string file contents of the QR code */ public function getUrl($qrtext, $size) { return 'https://api.qrserver.com/v1/create-qr-code/' . '?size=' . $size . 'x' . $size . '&ecc=' . strtoupper($this->errorcorrectionlevel) . '&margin=' . $this->margin . '&qzone=' . $this->qzone . '&bgcolor=' . $this->decodeColor($this->bgcolor) . '&color=' . $this->decodeColor($this->color) . '&format=' . strtolower($this->format) . '&data=' . rawurlencode($qrtext); } }