コード例 #1
0
 /**
  * Constructor
  *
  * @param string $text
  * @param int $modulesize
  */
 public function __construct($text, $moduleSize = 2, $allowedChars = null)
 {
     try {
         parent::__construct($text, $moduleSize);
         if ($allowedChars) {
             $this->checkAllowedChars($text, $allowedChars);
         }
     } catch (Exception $e) {
         throw $e;
     }
 }
コード例 #2
0
 /**
  * Constructor
  *
  * @param string $text
  * @param int $moduleSize
  * @param char $ecl
  */
 public function __construct($text, $moduleSize = parent::MODULE_SIZE, $ecl = self::ECL_L_CODE, $version = null)
 {
     try {
         parent::__construct($text, $moduleSize);
         // Convert input text to UTF-8
         $current_encoding = mb_detect_encoding($this->text, 'auto');
         $this->text = iconv($current_encoding, 'UTF-8', $this->text);
         $this->ecl = $this->eclConvertTable[$ecl];
         // Num of input chars
         $this->charsNum = strlen($text);
         $this->mode = $this->getMode($text);
         // Mask reference
         $this->maskReference = rand(0, 7);
         // Version
         $this->version = $this->getVersion($this->charsNum, $this->ecl, $this->mode, $version);
         // Code size
         $this->matrixSize = $this->getMatrixSize($this->version);
         $this->symbolSize = $this->matrixSize + 2 * self::QUIET_ZONE;
         $this->countGaloisField();
         // Init matrixes
         $this->init();
         $this->bitsCoordinates = $this->getBitsCoordinates($this->maskedMatrix);
         $this->convertData();
         // Format info
         $formatInformation = $this->formatInformation($this->ecl, $this->maskReference);
         $this->matrix = $this->addFormatInformation($this->matrix, $formatInformation);
         // Version info
         if ($this->version >= 7 && $this->version <= 40) {
             $versionInformation = $this->versionInformation($this->version);
             $this->matrix = $this->addVersionInformation($this->matrix, $versionInformation);
         }
     } catch (Exception $e) {
         throw $e;
     }
 }