Conditions | 3 |
Paths | 3 |
Total Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
14 | public static function getHumanReadableSize($sizeInBytes) |
||
15 | { |
||
16 | $units = ['B', 'KB', 'MB', 'GB', 'TB']; |
||
17 | |||
18 | if ($sizeInBytes === 0) { |
||
19 | return '0 '.$units[1]; |
||
20 | } |
||
21 | for ($i = 0; $sizeInBytes > 1024; ++$i) { |
||
22 | $sizeInBytes /= 1024; |
||
23 | } |
||
24 | |||
25 | return round($sizeInBytes, 2).' '.$units[$i]; |
||
26 | } |
||
27 | } |
||
28 |