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

Method init

text-to-qr/lib/phpqrcode/phpqrcode.php:2895–2935  ·  view source on GitHub ↗

----------------------------------------------------------------------

(array $spec)

Source from the content-addressed store, hash-verified

2893
2894 //----------------------------------------------------------------------
2895 public function init(array $spec)
2896 {
2897 $dl = QRspec::rsDataCodes1($spec);
2898 $el = QRspec::rsEccCodes1($spec);
2899 $rs = QRrs::init_rs(8, 0x11d, 0, 1, $el, 255 - $dl - $el);
2900
2901
2902 $blockNo = 0;
2903 $dataPos = 0;
2904 $eccPos = 0;
2905 for($i=0; $i<QRspec::rsBlockNum1($spec); $i++) {
2906 $ecc = array_slice($this->ecccode,$eccPos);
2907 $this->rsblocks[$blockNo] = new QRrsblock($dl, array_slice($this->datacode, $dataPos), $el, $ecc, $rs);
2908 $this->ecccode = array_merge(array_slice($this->ecccode,0, $eccPos), $ecc);
2909
2910 $dataPos += $dl;
2911 $eccPos += $el;
2912 $blockNo++;
2913 }
2914
2915 if(QRspec::rsBlockNum2($spec) == 0)
2916 return 0;
2917
2918 $dl = QRspec::rsDataCodes2($spec);
2919 $el = QRspec::rsEccCodes2($spec);
2920 $rs = QRrs::init_rs(8, 0x11d, 0, 1, $el, 255 - $dl - $el);
2921
2922 if($rs == NULL) return -1;
2923
2924 for($i=0; $i<QRspec::rsBlockNum2($spec); $i++) {
2925 $ecc = array_slice($this->ecccode,$eccPos);
2926 $this->rsblocks[$blockNo] = new QRrsblock($dl, array_slice($this->datacode, $dataPos), $el, $ecc, $rs);
2927 $this->ecccode = array_merge(array_slice($this->ecccode,0, $eccPos), $ecc);
2928
2929 $dataPos += $dl;
2930 $eccPos += $el;
2931 $blockNo++;
2932 }
2933
2934 return 0;
2935 }
2936
2937 //----------------------------------------------------------------------
2938 public function getCode()

Callers 1

__constructMethod · 0.95

Calls 7

rsDataCodes1Method · 0.45
rsEccCodes1Method · 0.45
init_rsMethod · 0.45
rsBlockNum1Method · 0.45
rsBlockNum2Method · 0.45
rsDataCodes2Method · 0.45
rsEccCodes2Method · 0.45

Tested by

no test coverage detected