$value * 1024 * 1024 * 1024, 'm' => $value * 1024 * 1024, 'k' => $value * 1024, default => $value, }; } function formatSize(int $bytes): string { if ($bytes >= 1024 * 1024 * 1024) { return round($bytes / (1024 * 1024 * 1024), 2) . ' GB'; } if ($bytes >= 1024 * 1024) { return round($bytes / (1024 * 1024), 2) . ' MB'; } if ($bytes >= 1024) { return round($bytes / 1024, 2) . ' KB'; } return $bytes . ' bytes'; }