| Conditions | 2 |
| Paths | 1 |
| Total Lines | 11 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 21 | public static function bytes($bytes, $precision = 2) |
||
| 22 | { |
||
| 23 | $units = array('b', 'KiB', 'MiB', 'GiB', 'TiB'); |
||
| 24 | |||
| 25 | $bytes = max($bytes, 0); |
||
| 26 | $pow = floor(($bytes ? log($bytes) : 0) / log(1024)); |
||
| 27 | $pow = min($pow, count($units) - 1); |
||
| 28 | $bytes /= (1 << (10 * $pow)); |
||
| 29 | |||
| 30 | return round($bytes, $precision) . ' ' . $units[$pow]; |
||
| 31 | } |
||
| 32 | |||
| 51 |