From 5147a3a3446338f5916b073b0000477557f54ffa Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Wed, 1 Mar 2017 19:55:09 +0000 Subject: [PATCH] Apply fixes from StyleCI --- lib/danog/PHP/Struct.php | 7 +++++-- lib/danog/PHP/StructTools.php | 8 +++++--- 2 files changed, 10 insertions(+), 5 deletions(-) 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); }