Check for inf values before try to converts bytes to binary prefix strings
This commit is contained in:
parent
037e181f82
commit
75b01f669a
|
@ -220,6 +220,11 @@ class Strings
|
||||||
*/
|
*/
|
||||||
public static function formatBytes(int $bytes, int $precision = 2): string
|
public static function formatBytes(int $bytes, int $precision = 2): string
|
||||||
{
|
{
|
||||||
|
// If this method is called for an infinite (== unlimited) amount of bytes:
|
||||||
|
if ($bytes == INF) {
|
||||||
|
return INF;
|
||||||
|
}
|
||||||
|
|
||||||
$units = ['B', 'KB', 'MB', 'GB', 'TB'];
|
$units = ['B', 'KB', 'MB', 'GB', 'TB'];
|
||||||
$bytes = max($bytes, 0);
|
$bytes = max($bytes, 0);
|
||||||
$pow = floor(($bytes ? log($bytes) : 0) / log(1024));
|
$pow = floor(($bytes ? log($bytes) : 0) / log(1024));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user