| Conditions | 3 | 
| Paths | 3 | 
| Total Lines | 19 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 0 | ||
| 1 | <?php | ||
| 36 | protected function bytesToHuman($bytes, $decimals = 2) | ||
| 37 |     { | ||
| 38 | $map = [ | ||
| 39 | 1000000000000 => 'TB', | ||
| 40 | 1000000000 => 'GB', | ||
| 41 | 1000000 => 'MB', | ||
| 42 | 1000 => 'KB', | ||
| 43 | 1 => 'B' | ||
| 44 | ]; | ||
| 45 | |||
| 46 |         foreach ($map as $val => $suffix) { | ||
| 47 |             if ($bytes >= $val) { | ||
| 48 | return number_format($bytes / $val, $decimals) . $suffix; | ||
| 49 | } | ||
| 50 | } | ||
| 51 | |||
| 52 | // Will make it here only if $bytes is < 1 | ||
| 53 | return number_format($bytes, $decimals) . 'B'; | ||
| 54 | } | ||
| 55 | } | ||
| 56 |