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

Method appendPaddingBit

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

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

(&$bstream)

Source from the content-addressed store, hash-verified

633
634 //----------------------------------------------------------------------
635 public function appendPaddingBit(&$bstream)
636 {
637 $bits = $bstream->size();
638 $maxwords = QRspec::getDataLength($this->version, $this->level);
639 $maxbits = $maxwords * 8;
640
641 if ($maxbits == $bits) {
642 return 0;
643 }
644
645 if ($maxbits - $bits < 5) {
646 return $bstream->appendNum($maxbits - $bits, 0);
647 }
648
649 $bits += 4;
650 $words = (int)(($bits + 7) / 8);
651
652 $padding = new QRbitstream();
653 $ret = $padding->appendNum($words * 8 - $bits + 4, 0);
654
655 if($ret < 0)
656 return $ret;
657
658 $padlen = $maxwords - $words;
659
660 if($padlen > 0) {
661
662 $padbuf = array();
663 for($i=0; $i<$padlen; $i++) {
664 $padbuf[$i] = ($i&1)?0x11:0xec;
665 }
666
667 $ret = $padding->appendBytes($padlen, $padbuf);
668
669 if($ret < 0)
670 return $ret;
671
672 }
673
674 $ret = $bstream->append($padding);
675
676 return $ret;
677 }
678
679 //----------------------------------------------------------------------
680 public function mergeBitStream()

Callers 1

getBitStreamMethod · 0.95

Calls 5

sizeMethod · 0.45
getDataLengthMethod · 0.45
appendNumMethod · 0.45
appendBytesMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected