예제 #1
0
 /**
  * @param $strContent
  * @param string $strType
  * @param int $intSize
  * @return string
  * @throws \Exception
  */
 public static function generate($strContent, $strType = self::QRCODE_H, $intSize = 3)
 {
     // Handle size
     if (!is_numeric($intSize) || $intSize < 1 || $intSize > 10) {
         $intSize = 3;
     }
     $strPath = 'qrcode/cache';
     $strAbsolutePath = \System::getContainer()->get('kernel')->getRootDir() . '/../web/' . $strPath . '/';
     $objQrcode = new Base2DBarcode();
     $objQrcode->savePath = $strAbsolutePath;
     $strAbsoluteFilePath = $objQrcode->getBarcodePNGPath($strContent, $strType, $intSize, $intSize);
     $strFile = substr($strAbsoluteFilePath, strlen($strAbsolutePath));
     return $strPath . '/' . $strFile;
 }
 /**
  * QRCode 2D Matrix-Code PNG rendering test
  *
  * @covers BG\BarcodeBundle\Util\Base2DBarcode::getBarcodePNGPath();
  */
 public function testQRCODEGetBarcodePNGPath()
 {
     $d2 = new matrixCode();
     $d2->savePath = '/tmp/';
     $bcPathAbs = $d2->getBarcodePNGPath(self::C_MC_DEFAULT, 'qrcode', self::C_MC_2D_WIDTH, self::C_MC_2D_HEIGHT);
     if (function_exists('imagecreate')) {
         $checkCondition = file_exists($bcPathAbs) && (filesize($bcPathAbs) > 225 && filesize($bcPathAbs) < 255);
     } else {
         $checkCondition = file_exists($bcPathAbs) ? true : false;
     }
     unlink($bcPathAbs);
     $this->assertTrue($checkCondition);
 }