/**
  * Verifies if this instance equals another one.
  *
  * @param  mixed $other
  * @return boolean
  */
 public function equals($other)
 {
     if (!$other instanceof self) {
         return false;
     }
     return $this->ecLevel->get() === $other->getErrorCorrectionLevel()->get() && $this->dataMask === $other->getDataMask();
 }
 private function __construct($formatInfo)
 {
     // Bits 3,4
     $this->errorCorrectionLevel = ErrorCorrectionLevel::forBits($formatInfo >> 3 & 0x3);
     // Bottom 3 bits
     $this->dataMask = $formatInfo & 0x7;
     //(byte)
 }
 /**
  * Create a URI that will generate a QR code with the supplied values.
  *
  * @param string                    $data            The data to encode.
  * @param integer|null              $size            The size of the QR code. The units are implementation dependant.
  * @param ErrorCorrectionLevel|null $errorCorrection The level of error correction to use.
  *
  * @return string The QR code URI.
  */
 public function createUri($data, $size = null, ErrorCorrectionLevel $errorCorrection = null)
 {
     if (null === $size) {
         $size = 250;
     }
     if (null === $errorCorrection) {
         $errorCorrection = ErrorCorrectionLevel::LOW();
     }
     if (ErrorCorrectionLevel::LOW() === $errorCorrection) {
         $errorCorrectionString = '';
     } else {
         $errorCorrectionString = $errorCorrection->letterCode();
     }
     return sprintf('https://chart.googleapis.com/chart?cht=qr' . '&chs=%sx%s&chld=%s%%7C0&chl=%s', rawurlencode($size), rawurlencode($size), $errorCorrectionString, rawurlencode($data));
 }
 /**
  * Create a URI that will generate a QR code with the supplied values.
  *
  * @param string                    $data            The data to encode.
  * @param integer|null              $size            The size of the QR code. The units are implementation dependant.
  * @param ErrorCorrectionLevel|null $errorCorrection The level of error correction to use.
  *
  * @return string The QR code URI.
  */
 public function createUri($data, $size = null, ErrorCorrectionLevel $errorCorrection = null)
 {
     if (null === $size) {
         $size = 250;
     }
     if (null === $errorCorrection) {
         $errorCorrection = ErrorCorrectionLevel::LOW();
     }
     $parameters = '';
     if (250 !== $size) {
         $parameters .= sprintf('&size=%sx%s', rawurlencode($size), rawurlencode($size));
     }
     if (ErrorCorrectionLevel::LOW() !== $errorCorrection) {
         $parameters .= '&ecc=' . rawurlencode($errorCorrection->letterCode());
     }
     return sprintf('https://api.qrserver.com/v1/create-qr-code/?data=%s%s', rawurlencode($data), $parameters);
 }
 /**
  * Create a URI that will generate a QR code with the supplied values.
  *
  * @param string                    $data            The data to encode.
  * @param integer|null              $size            The size of the QR code. The units are implementation dependant.
  * @param ErrorCorrectionLevel|null $errorCorrection The level of error correction to use.
  *
  * @return string The QR code URI.
  */
 public function createUri($data, $size = null, ErrorCorrectionLevel $errorCorrection = null)
 {
     if (null === $size) {
         $size = 8;
     }
     if (null === $errorCorrection) {
         $errorCorrection = ErrorCorrectionLevel::LOW();
     }
     $parameters = '';
     if (8 !== $size) {
         $parameters .= '&s=' . rawurlencode($size);
     }
     if (ErrorCorrectionLevel::MEDIUM() !== $errorCorrection) {
         $parameters .= '&l=' . rawurlencode($errorCorrection->numberCode());
     }
     return sprintf('http://qrfree.kaywa.com/?d=%s%s', rawurlencode($data), $parameters);
 }
    //self::$Q = new ErrorCorrectionLevel(0x03);
    /** H = ~30% correction */
    //self::$H = new ErrorCorrectionLevel(0x02);
    public function getBits()
    {
        return $this->bits;
    }
    public function toString()
    {
        return $this->bits;
    }
    public function getOrdinal()
    {
        return $this->ordinal;
    }
    /**
     * @param bits int containing the two bits encoding a QR Code's error correction level
     * @return ErrorCorrectionLevel representing the encoded error correction level
     */
    public static function forBits($bits)
    {
        if ($bits < 0 || $bits >= count(self::$FOR_BITS)) {
            throw new InvalidArgumentException();
        }
        $level = self::$FOR_BITS[$bits];
        // $lev = self::$$bit;
        return $level;
    }
}
ErrorCorrectionLevel::Init();