Exemplo n.º 1
0
 /**
  * @param string $text
  * @return array|int
  * @throws InvalidConfigException
  */
 private function generateQr($text = '')
 {
     $image = null;
     $outfile = false;
     $level = Enum::QR_ECLEVEL_L;
     $size = 3;
     $margin = 4;
     $save = false;
     $type = Enum::QR_FORMAT_JPG;
     foreach ($this->QrParams as $name => $param) {
         switch ($name) {
             case 'outfile':
                 $outfile = $this->checkParamOutfile($param);
                 break;
             case 'level':
                 $level = $this->checkParamLevel($param);
                 break;
             case 'size':
                 $size = $this->checkParamSize($param);
                 break;
             case 'margin':
                 $margin = $this->checkParamMargin($param);
                 break;
             case 'save':
                 $save = $this->checkParamSave($param);
                 break;
             case 'type':
                 $type = $this->checkParamType($param);
                 break;
         }
     }
     QrCode::encode($text, $outfile, $level, $size, $margin, false, $type);
     if (is_file($outfile)) {
         $image = file_get_contents($outfile);
     }
     if (!$save) {
         unlink($outfile);
     }
     return $image;
 }