File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change 2424class Util {
2525 private static $ little_endian = null ;
2626
27+ /**
28+ * Reads data
29+ *
30+ * @param string $type type for unpack()
31+ * @param string $data Data to process
32+ *
33+ * @return mixed
34+ */
2735 public static function loadData ($ type , $ data ) {
2836 if (!$ data ) {
2937 return $ data ;
@@ -32,6 +40,13 @@ public static function loadData($type, $data) {
3240 return current ($ tmp );
3341 }
3442
43+ /**
44+ * Changes endianity
45+ *
46+ * @param string $value Binary value
47+ *
48+ * @return string
49+ */
3550 public static function swap($ binValue ) {
3651 $ result = $ binValue {strlen ($ binValue ) - 1 };
3752 for ($ i = strlen ($ binValue ) - 2 ; $ i >= 0 ; $ i --) {
@@ -41,6 +56,13 @@ public static function swap($binValue) {
4156 return $ result ;
4257 }
4358
59+ /**
60+ * Encodes double value to correct endianity
61+ *
62+ * @param double $value Value to pack
63+ *
64+ * @return string
65+ */
4466 public static function packDouble ($ value ) {
4567 $ bin = pack ("d " , (double ) $ value );
4668
You can’t perform that action at this time.
0 commit comments