| 1 | <?php |
||
| 10 | class Binary |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * Check if machine endian format is big endian format. |
||
| 14 | * |
||
| 15 | * @var bool |
||
| 16 | */ |
||
| 17 | private static $isBigEndian = false; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * Initialize flags. |
||
| 21 | */ |
||
| 22 | 1 | public static function init() |
|
| 26 | |||
| 27 | /** |
||
| 28 | * Pack a value and enforce big endian format. |
||
| 29 | * |
||
| 30 | * @param string $format |
||
| 31 | * @param string $value |
||
| 32 | * |
||
| 33 | * @return string |
||
| 34 | */ |
||
| 35 | 39 | public static function packbe($format, $value) |
|
| 39 | |||
| 40 | /** |
||
| 41 | * Unpack a value. |
||
| 42 | * |
||
| 43 | * @param string $format |
||
| 44 | * @param string $data |
||
| 45 | * |
||
| 46 | * @return string |
||
| 47 | */ |
||
| 48 | public static function unpack($format, $data) |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Unpack a value and enforce big endian format. |
||
| 55 | * |
||
| 56 | * @param string $format |
||
| 57 | * @param string $data |
||
| 58 | * |
||
| 59 | * @return string |
||
| 60 | */ |
||
| 61 | 39 | public static function unpackbe($format, $data) |
|
| 65 | } |
||
| 66 |