Example #1
0
 public static function getInstance()
 {
     if (!isset(self::$iInstance)) {
         $c = __CLASS__;
         self::$iInstance = new $c();
     }
     return self::$iInstance;
 }
Example #2
0
 function addVersionInfo()
 {
     if ($this->iVersion >= 7) {
         $bitstring = QRCapacity::getInstance()->getVersionBits($this->iVersion);
         $n = $this->QRCap->getDimension($this->iVersion);
         $this->_dbgInfo(4, "Adding version = {$this->iVersion} bits: " . $bitstring . "\n");
         $idx = 0;
         for ($c = 0; $c < 6; ++$c) {
             for ($r = $n - 11; $r < $n - 8; ++$r) {
                 // Position first set (Bottom-Left)
                 $this->iMatrix[$r][$c] = substr($bitstring, $idx, 1);
                 // Position second set (Upper right)
                 $this->iMatrix[$c][$r] = substr($bitstring, $idx++, 1);
             }
         }
     }
 }
Example #3
0
 function __construct($aVersion = -1, $aErrLevel = QRCapacity::ErrM)
 {
     $this->SetSize($aVersion);
     // If error level is set < 0 this is interpretated as that the user
     // wants us to choose the level of error redundancy.
     if ($aErrLevel < 0) {
         if ($aVersion > 30) {
             $aErrLevel = QRCapacity::ErrH;
             // Use more error redundancy for large data
             $this->iGeneralInfo .= "Automatically set error level to H\n";
         } elseif ($aVersion > 20) {
             $aErrLevel = QRCapacity::ErrQ;
             // Use more error redundancy for large data
             $this->iGeneralInfo .= "Automatically set error level to Q\n";
         } else {
             $aErrLevel = QRCapacity::ErrM;
             $this->iGeneralInfo .= "Automatically set error level to M\n";
         }
     }
     $this->iErrLevel = $aErrLevel;
     // Initialize translation table for alphanumeric
     for ($i = 0; $i < 10; ++$i) {
         $this->iAlphaNumTable[ord('0') + $i] = $i;
     }
     for ($i = 0; $i < 26; ++$i) {
         $this->iAlphaNumTable[ord('A') + $i] = 10 + $i;
     }
     $punct = array(ord(' ') => 36, ord('$') => 37, ord('%') => 38, ord('*') => 39, ord('+') => 40, ord('-') => 41, ord('.') => 42, ord('/') => 43, ord(':') => 44);
     $this->iAlphaNumTable = $this->iAlphaNumTable + $punct;
     foreach ($this->iAlphaNumTable as $key => $val) {
         $this->iAlphaNumInvTable[$val] = $key;
     }
     $this->iQRCapacity = QRCapacity::getInstance();
     $this->iQRMask = QRMask::getInstance();
 }