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

Method newFromNum

text-to-qr/lib/phpqrcode/qrbitstream.php:46–62  ·  view source on GitHub ↗

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

($bits, $num)

Source from the content-addressed store, hash-verified

44
45 //----------------------------------------------------------------------
46 public static function newFromNum($bits, $num)
47 {
48 $bstream = new QRbitstream();
49 $bstream->allocate($bits);
50
51 $mask = 1 << ($bits - 1);
52 for($i=0; $i<$bits; $i++) {
53 if($num & $mask) {
54 $bstream->data[$i] = 1;
55 } else {
56 $bstream->data[$i] = 0;
57 }
58 $mask = $mask >> 1;
59 }
60
61 return $bstream;
62 }
63
64 //----------------------------------------------------------------------
65 public static function newFromBytes($size, $data)

Callers 1

appendNumMethod · 0.45

Calls 1

allocateMethod · 0.45

Tested by

no test coverage detected