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

Method eat8

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

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

()

Source from the content-addressed store, hash-verified

2128
2129 //----------------------------------------------------------------------
2130 public function eat8()
2131 {
2132 $la = QRspec::lengthIndicator(QR_MODE_AN, $this->input->getVersion());
2133 $ln = QRspec::lengthIndicator(QR_MODE_NUM, $this->input->getVersion());
2134
2135 $p = 1;
2136 $dataStrLen = strlen($this->dataStr);
2137
2138 while($p < $dataStrLen) {
2139
2140 $mode = $this->identifyMode($p);
2141 if($mode == QR_MODE_KANJI) {
2142 break;
2143 }
2144 if($mode == QR_MODE_NUM) {
2145 $q = $p;
2146 while(self::isdigitat($this->dataStr, $q)) {
2147 $q++;
2148 }
2149 $dif = QRinput::estimateBitsMode8($p) // + 4 + l8
2150 + QRinput::estimateBitsModeNum($q - $p) + 4 + $ln
2151 - QRinput::estimateBitsMode8($q); // - 4 - l8
2152 if($dif < 0) {
2153 break;
2154 } else {
2155 $p = $q;
2156 }
2157 } else if($mode == QR_MODE_AN) {
2158 $q = $p;
2159 while(self::isalnumat($this->dataStr, $q)) {
2160 $q++;
2161 }
2162 $dif = QRinput::estimateBitsMode8($p) // + 4 + l8
2163 + QRinput::estimateBitsModeAn($q - $p) + 4 + $la
2164 - QRinput::estimateBitsMode8($q); // - 4 - l8
2165 if($dif < 0) {
2166 break;
2167 } else {
2168 $p = $q;
2169 }
2170 } else {
2171 $p++;
2172 }
2173 }
2174
2175 $run = $p;
2176 $ret = $this->input->append(QR_MODE_8, $run, str_split($this->dataStr));
2177
2178 if($ret < 0)
2179 return -1;
2180
2181 return $run;
2182 }
2183
2184 //----------------------------------------------------------------------
2185 public function splitString()

Callers 3

eatNumMethod · 0.95
eatAnMethod · 0.95
splitStringMethod · 0.95

Calls 10

identifyModeMethod · 0.95
isdigitatMethod · 0.95
isalnumatMethod · 0.95
str_splitFunction · 0.85
lengthIndicatorMethod · 0.45
getVersionMethod · 0.45
estimateBitsMode8Method · 0.45
estimateBitsModeNumMethod · 0.45
estimateBitsModeAnMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected