Conditions | 5 |
Paths | 12 |
Total Lines | 15 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
16 | function uint32($i, bool $endianness = null){ |
||
17 | |||
18 | if($endianness === true){ // big-endian |
||
19 | $f = 'N'; |
||
20 | } |
||
21 | elseif($endianness === false){ // little-endian |
||
22 | $f = 'V'; |
||
23 | } |
||
24 | else{ // machine byte order |
||
25 | $f = 'L'; |
||
26 | } |
||
27 | |||
28 | $i = is_int($i) ? pack($f, $i) : unpack($f, $i); |
||
29 | |||
30 | return is_array($i) ? $i[1] : $i; |
||
31 | } |
||
66 |