diff --git a/lib/danog/PHP/Struct.php b/lib/danog/PHP/Struct.php index 664ae77..c298f86 100644 --- a/lib/danog/PHP/Struct.php +++ b/lib/danog/PHP/Struct.php @@ -23,13 +23,14 @@ class Struct * Istantiates the PHPStruct class in a static variable * * @param $format Format string - * */ - public static function constructor() { + public static function constructor() + { if (self::$struct == null) { self::$struct = new \danog\PHP\StructTools(); } } + /** * pack. * @@ -43,6 +44,7 @@ class Struct public static function pack($format, ...$data) { self::constructor(); + return self::$struct->pack($format, ...$data); } @@ -59,6 +61,7 @@ class Struct public static function unpack($format, $data) { self::constructor(); + return self::$struct->unpack($format, $data); } diff --git a/lib/danog/PHP/StructTools.php b/lib/danog/PHP/StructTools.php index 5557e68..2801c20 100644 --- a/lib/danog/PHP/StructTools.php +++ b/lib/danog/PHP/StructTools.php @@ -549,7 +549,7 @@ class StructTools } /** - * data2array + * data2array. * * Convert a binary string to an array based on the given format string * @@ -689,10 +689,12 @@ class StructTools { if (!$unsigned && $binary[0] == '1') { foreach (str_split($binary) as $key => $char) { - $binary[$key] =(int)!$char; + $binary[$key] = (int) !$char; } - return -(bindec($binary)+1); + + return -(bindec($binary) + 1); } + return bindec($binary); }