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

Method toByte

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

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

()

Source from the content-addressed store, hash-verified

1890
1891 //----------------------------------------------------------------------
1892 public function toByte()
1893 {
1894
1895 $size = $this->size();
1896
1897 if($size == 0) {
1898 return array();
1899 }
1900
1901 $data = array_fill(0, (int)(($size + 7) / 8), 0);
1902 $bytes = (int)($size / 8);
1903
1904 $p = 0;
1905
1906 for($i=0; $i<$bytes; $i++) {
1907 $v = 0;
1908 for($j=0; $j<8; $j++) {
1909 $v = $v << 1;
1910 $v |= $this->data[$p];
1911 $p++;
1912 }
1913 $data[$i] = $v;
1914 }
1915
1916 if($size & 7) {
1917 $v = 0;
1918 for($j=0; $j<($size & 7); $j++) {
1919 $v = $v << 1;
1920 $v |= $this->data[$p];
1921 $p++;
1922 }
1923 $data[$bytes] = $v;
1924 }
1925
1926 return $data;
1927 }
1928
1929 }
1930

Callers 2

getByteStreamMethod · 0.45
getByteStreamMethod · 0.45

Calls 1

sizeMethod · 0.95

Tested by

no test coverage detected