/**
  * Create a URI that will generate a QR code with the supplied values.
  *
  * @param string                    $data            The data to encode.
  * @param integer|null              $size            The size of the QR code. The units are implementation dependant.
  * @param ErrorCorrectionLevel|null $errorCorrection The level of error correction to use.
  *
  * @return string The QR code URI.
  */
 public function createUri($data, $size = null, ErrorCorrectionLevel $errorCorrection = null)
 {
     if (null === $size) {
         $size = 250;
     }
     if (null === $errorCorrection) {
         $errorCorrection = ErrorCorrectionLevel::LOW();
     }
     if (ErrorCorrectionLevel::LOW() === $errorCorrection) {
         $errorCorrectionString = '';
     } else {
         $errorCorrectionString = $errorCorrection->letterCode();
     }
     return sprintf('https://chart.googleapis.com/chart?cht=qr' . '&chs=%sx%s&chld=%s%%7C0&chl=%s', rawurlencode($size), rawurlencode($size), $errorCorrectionString, rawurlencode($data));
 }
 /**
  * Create a URI that will generate a QR code with the supplied values.
  *
  * @param string                    $data            The data to encode.
  * @param integer|null              $size            The size of the QR code. The units are implementation dependant.
  * @param ErrorCorrectionLevel|null $errorCorrection The level of error correction to use.
  *
  * @return string The QR code URI.
  */
 public function createUri($data, $size = null, ErrorCorrectionLevel $errorCorrection = null)
 {
     if (null === $size) {
         $size = 250;
     }
     if (null === $errorCorrection) {
         $errorCorrection = ErrorCorrectionLevel::LOW();
     }
     $parameters = '';
     if (250 !== $size) {
         $parameters .= sprintf('&size=%sx%s', rawurlencode($size), rawurlencode($size));
     }
     if (ErrorCorrectionLevel::LOW() !== $errorCorrection) {
         $parameters .= '&ecc=' . rawurlencode($errorCorrection->letterCode());
     }
     return sprintf('https://api.qrserver.com/v1/create-qr-code/?data=%s%s', rawurlencode($data), $parameters);
 }
Example #3
0
 /**
  * Create a URI that will generate a QR code with the supplied values.
  *
  * @param string                    $data            The data to encode.
  * @param integer|null              $size            The size of the QR code. The units are implementation dependant.
  * @param ErrorCorrectionLevel|null $errorCorrection The level of error correction to use.
  *
  * @return string The QR code URI.
  */
 public function createUri($data, $size = null, ErrorCorrectionLevel $errorCorrection = null)
 {
     if (null === $size) {
         $size = 8;
     }
     if (null === $errorCorrection) {
         $errorCorrection = ErrorCorrectionLevel::LOW();
     }
     $parameters = '';
     if (8 !== $size) {
         $parameters .= '&s=' . rawurlencode($size);
     }
     if (ErrorCorrectionLevel::MEDIUM() !== $errorCorrection) {
         $parameters .= '&l=' . rawurlencode($errorCorrection->numberCode());
     }
     return sprintf('http://qrfree.kaywa.com/?d=%s%s', rawurlencode($data), $parameters);
 }