| Conditions | 3 |
| Paths | 3 |
| Total Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 9 | public static function humanReadableSize(float $sizeInBytes): string |
||
| 10 | { |
||
| 11 | $units = ['B', 'KB', 'MB', 'GB', 'TB']; |
||
| 12 | |||
| 13 | if ($sizeInBytes === 0) { |
||
| 14 | return '0 '.$units[1]; |
||
| 15 | } |
||
| 16 | for ($i = 0; $sizeInBytes > 1024; $i++) { |
||
| 17 | $sizeInBytes /= 1024; |
||
| 18 | } |
||
| 19 | |||
| 20 | return round($sizeInBytes, 2).' '.$units[$i]; |
||
| 21 | } |
||
| 22 | |||
| 37 |