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

Method encodeModeNum

text-to-qr/lib/phpqrcode/qrinput.php:58–91  ·  view source on GitHub ↗

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

($version)

Source from the content-addressed store, hash-verified

56
57 //----------------------------------------------------------------------
58 public function encodeModeNum($version)
59 {
60 try {
61
62 $words = (int)($this->size / 3);
63 $bs = new QRbitstream();
64
65 $val = 0x1;
66 $bs->appendNum(4, $val);
67 $bs->appendNum(QRspec::lengthIndicator(QR_MODE_NUM, $version), $this->size);
68
69 for($i=0; $i<$words; $i++) {
70 $val = (ord($this->data[$i*3 ]) - ord('0')) * 100;
71 $val += (ord($this->data[$i*3+1]) - ord('0')) * 10;
72 $val += (ord($this->data[$i*3+2]) - ord('0'));
73 $bs->appendNum(10, $val);
74 }
75
76 if($this->size - $words * 3 == 1) {
77 $val = ord($this->data[$words*3]) - ord('0');
78 $bs->appendNum(4, $val);
79 } else if($this->size - $words * 3 == 2) {
80 $val = (ord($this->data[$words*3 ]) - ord('0')) * 10;
81 $val += (ord($this->data[$words*3+1]) - ord('0'));
82 $bs->appendNum(7, $val);
83 }
84
85 $this->bstream = $bs;
86 return 0;
87
88 } catch (Exception $e) {
89 return -1;
90 }
91 }
92
93 //----------------------------------------------------------------------
94 public function encodeModeAn($version)

Callers 1

encodeBitStreamMethod · 0.95

Calls 2

appendNumMethod · 0.45
lengthIndicatorMethod · 0.45

Tested by

no test coverage detected