예제 #1
0
 /**
  * Generates a QrCode
  *
  * @param string $text The text to be converted into a QrCode
  * @param null|string $filename The filename and path to save the QrCode file
  * @return string|void Returns a QrCode string depending on the format, or saves to a file.
  */
 public function generate($text, $filename = null)
 {
     if ($filename === null) {
         return $this->writer->writeString($text, $this->encoding, $this->errorCorrection);
     } else {
         $this->writer->writeFile($text, $filename, $this->encoding, $this->errorCorrection);
     }
 }
 /**
  * Generates a QrCode.
  *
  * @param string      $text     The text to be converted into a QrCode
  * @param null|string $filename The filename and path to save the QrCode file
  *
  * @return string|void Returns a QrCode string depending on the format, or saves to a file.
  */
 public function generate($text, $filename = null)
 {
     $qrCode = $this->writer->writeString($text, $this->encoding, $this->errorCorrection);
     if ($this->imageMerge !== null) {
         $merger = new ImageMerge(new Image($qrCode), new Image($this->imageMerge));
         $qrCode = $merger->merge($this->imagePercentage);
     }
     if ($filename === null) {
         return $qrCode;
     } else {
         file_put_contents($filename, $qrCode);
     }
 }