/** * Gets the number of EC blocks for a specific EC level. * * @param ErrorCorrectionLevel $ecLevel * @return integer */ public function getEcBlocksForLevel(ErrorCorrectionLevel $ecLevel) { return $this->errorCorrectionBlocks[$ecLevel->getOrdinal()]; }
/** * Generates type information bits and appends them to a bit array. * * @param ErrorCorrectionLevel $level * @param integer $maskPattern * @param BitArray $bits * @return void * @throws Exception\RuntimeException */ protected static function makeTypeInfoBits(ErrorCorrectionLevel $level, $maskPattern, BitArray $bits) { $typeInfo = $level->get() << 3 | $maskPattern; $bits->appendBits($typeInfo, 5); $bchCode = self::calculateBchCode($typeInfo, self::$typeInfoPoly); $bits->appendBits($bchCode, 10); $maskBits = new BitArray(); $maskBits->appendBits(self::$typeInfoMaskPattern, 15); $bits->xorBits($maskBits); if ($bits->getSize() !== 15) { throw new Exception\RuntimeException('Bit array resulted in invalid size: ' . $bits->getSize()); } }