/** * @param Input $input */ public function __construct(Input $input) { $spec = array(0, 0, 0, 0, 0); $this->dataCode = $input->getByteStream(); if (is_null($this->dataCode)) { throw new InvalidConfigException('null input string'); } Specifications::getEccSpec($input->getVersion(), $input->getErrorCorrectionLevel(), $spec); $this->version = $input->getVersion(); $this->b1 = Specifications::rsBlockNum1($spec); $this->dataLength = Specifications::rsDataLength($spec); $this->eccLength = Specifications::rsEccLength($spec); $this->eccCode = array_fill(0, $this->eccLength, 0); $this->blocks = Specifications::rsBlockNum($spec); $ret = $this->init($spec); if ($ret < 0) { throw new \Exception('block alloc error'); } $this->count = 0; }