MCPcopy Create free account
hub / github.com/codemistic/Web-Development / init

Method init

text-to-qr/lib/phpqrcode/bindings/tcpdf/qrcode.php:872–917  ·  view source on GitHub ↗

* Initialize code. * @param array $spec array of ECC specification * @return 0 in case of success, -1 in case of error */

($spec)

Source from the content-addressed store, hash-verified

870 * @return 0 in case of success, -1 in case of error
871 */
872 protected function init($spec) {
873 $dl = $this->rsDataCodes1($spec);
874 $el = $this->rsEccCodes1($spec);
875 $rs = $this->init_rs(8, 0x11d, 0, 1, $el, 255 - $dl - $el);
876 $blockNo = 0;
877 $dataPos = 0;
878 $eccPos = 0;
879 $endfor = $this->rsBlockNum1($spec);
880 for ($i=0; $i < $endfor; ++$i) {
881 $ecc = array_slice($this->ecccode, $eccPos);
882 $this->rsblocks[$blockNo] = array();
883 $this->rsblocks[$blockNo]['dataLength'] = $dl;
884 $this->rsblocks[$blockNo]['data'] = array_slice($this->datacode, $dataPos);
885 $this->rsblocks[$blockNo]['eccLength'] = $el;
886 $ecc = $this->encode_rs_char($rs, $this->rsblocks[$blockNo]['data'], $ecc);
887 $this->rsblocks[$blockNo]['ecc'] = $ecc;
888 $this->ecccode = array_merge(array_slice($this->ecccode,0, $eccPos), $ecc);
889 $dataPos += $dl;
890 $eccPos += $el;
891 $blockNo++;
892 }
893 if ($this->rsBlockNum2($spec) == 0) {
894 return 0;
895 }
896 $dl = $this->rsDataCodes2($spec);
897 $el = $this->rsEccCodes2($spec);
898 $rs = $this->init_rs(8, 0x11d, 0, 1, $el, 255 - $dl - $el);
899 if ($rs == NULL) {
900 return -1;
901 }
902 $endfor = $this->rsBlockNum2($spec);
903 for ($i=0; $i < $endfor; ++$i) {
904 $ecc = array_slice($this->ecccode, $eccPos);
905 $this->rsblocks[$blockNo] = array();
906 $this->rsblocks[$blockNo]['dataLength'] = $dl;
907 $this->rsblocks[$blockNo]['data'] = array_slice($this->datacode, $dataPos);
908 $this->rsblocks[$blockNo]['eccLength'] = $el;
909 $ecc = $this->encode_rs_char($rs, $this->rsblocks[$blockNo]['data'], $ecc);
910 $this->rsblocks[$blockNo]['ecc'] = $ecc;
911 $this->ecccode = array_merge(array_slice($this->ecccode, 0, $eccPos), $ecc);
912 $dataPos += $dl;
913 $eccPos += $el;
914 $blockNo++;
915 }
916 return 0;
917 }
918
919 /**
920 * Return Reed-Solomon block code.

Callers 1

encodeMaskMethod · 0.95

Calls 8

rsDataCodes1Method · 0.95
rsEccCodes1Method · 0.95
init_rsMethod · 0.95
rsBlockNum1Method · 0.95
encode_rs_charMethod · 0.95
rsBlockNum2Method · 0.95
rsDataCodes2Method · 0.95
rsEccCodes2Method · 0.95

Tested by

no test coverage detected