mirror of
https://github.com/danog/PHPStruct.git
synced 2024-11-30 04:19:08 +01:00
Apply fixes from StyleCI
This commit is contained in:
parent
762e61372a
commit
5147a3a344
@ -23,13 +23,14 @@ class Struct
|
|||||||
* Istantiates the PHPStruct class in a static variable
|
* Istantiates the PHPStruct class in a static variable
|
||||||
*
|
*
|
||||||
* @param $format Format string
|
* @param $format Format string
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public static function constructor() {
|
public static function constructor()
|
||||||
|
{
|
||||||
if (self::$struct == null) {
|
if (self::$struct == null) {
|
||||||
self::$struct = new \danog\PHP\StructTools();
|
self::$struct = new \danog\PHP\StructTools();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pack.
|
* pack.
|
||||||
*
|
*
|
||||||
@ -43,6 +44,7 @@ class Struct
|
|||||||
public static function pack($format, ...$data)
|
public static function pack($format, ...$data)
|
||||||
{
|
{
|
||||||
self::constructor();
|
self::constructor();
|
||||||
|
|
||||||
return self::$struct->pack($format, ...$data);
|
return self::$struct->pack($format, ...$data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,6 +61,7 @@ class Struct
|
|||||||
public static function unpack($format, $data)
|
public static function unpack($format, $data)
|
||||||
{
|
{
|
||||||
self::constructor();
|
self::constructor();
|
||||||
|
|
||||||
return self::$struct->unpack($format, $data);
|
return self::$struct->unpack($format, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -549,7 +549,7 @@ class StructTools
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* data2array
|
* data2array.
|
||||||
*
|
*
|
||||||
* Convert a binary string to an array based on the given format string
|
* Convert a binary string to an array based on the given format string
|
||||||
*
|
*
|
||||||
@ -689,10 +689,12 @@ class StructTools
|
|||||||
{
|
{
|
||||||
if (!$unsigned && $binary[0] == '1') {
|
if (!$unsigned && $binary[0] == '1') {
|
||||||
foreach (str_split($binary) as $key => $char) {
|
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);
|
return bindec($binary);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user