本文整理汇总了PHP中QRspec::maximumWords方法的典型用法代码示例。如果您正苦于以下问题:PHP QRspec::maximumWords方法的具体用法?PHP QRspec::maximumWords怎么用?PHP QRspec::maximumWords使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QRspec
的用法示例。
在下文中一共展示了QRspec::maximumWords方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: lengthOfCode
public static function lengthOfCode($mode, $version, $bits)
{
$payload = $bits - 4 - QRspec::lengthIndicator($mode, $version);
switch ($mode) {
case QR_MODE_NUM:
$chunks = (int) ($payload / 10);
$remain = $payload - $chunks * 10;
$size = $chunks * 3;
if ($remain >= 7) {
$size += 2;
} else {
if ($remain >= 4) {
$size += 1;
}
}
break;
case QR_MODE_AN:
$chunks = (int) ($payload / 11);
$remain = $payload - $chunks * 11;
$size = $chunks * 2;
if ($remain >= 6) {
$size++;
}
break;
case QR_MODE_8:
$size = (int) ($payload / 8);
break;
case QR_MODE_KANJI:
$size = (int) ($payload / 13 * 2);
break;
case QR_MODE_STRUCTURE:
$size = (int) ($payload / 8);
break;
default:
$size = 0;
break;
}
$maxsize = QRspec::maximumWords($mode, $version);
if ($size < 0) {
$size = 0;
}
if ($size > $maxsize) {
$size = $maxsize;
}
return $size;
}
示例2: encodeBitStream
public function encodeBitStream($version)
{
try {
unset($this->bstream);
$words = QRspec::maximumWords($this->mode, $version);
if ($this->size > $words) {
$st1 = new QRinputitem($this->mode, $words, $this->data);
$st2 = new QRinputitem($this->mode, $this->size - $words, array_slice($this->data, $words));
$st1->encodeBitStream($version);
$st2->encodeBitStream($version);
$this->bstream = new QRbitstream();
$this->bstream->append($st1->bstream);
$this->bstream->append($st2->bstream);
unset($st1);
unset($st2);
} else {
$ret = 0;
switch ($this->mode) {
case QR_MODE_NUM:
$ret = $this->encodeModeNum($version);
break;
case QR_MODE_AN:
$ret = $this->encodeModeAn($version);
break;
case QR_MODE_8:
$ret = $this->encodeMode8($version);
break;
case QR_MODE_KANJI:
$ret = $this->encodeModeKanji($version);
break;
case QR_MODE_STRUCTURE:
$ret = $this->encodeModeStructure();
break;
default:
break;
}
if ($ret < 0) {
return -1;
}
}
return $this->bstream->size();
} catch (Exception $e) {
return -1;
}
}