src/includes/classes/Core/Utils/FileSize.php
public function bytesAbbr(float $bytes, int $precision = 2): string
    {
        $bytes      = max(0, (int) $bytes);
        $precision  = max(0, $precision);

        $units      = ['bytes', 'kbs', 'MB', 'GB', 'TB'];
        $power      = floor(($bytes ? log($bytes) : 0) / log(1024));
        $abbr_bytes = round($bytes / pow(1024, $power), $precision);
        $abbr       = $units[min($power, count($units) - 1)];

        if ($abbr_bytes === (float) 1 && $abbr === 'bytes') {
            $abbr = 'byte'; // Quick fix.
        } elseif ($abbr_bytes === (float) 1 && $abbr === 'kbs') {
            $abbr = 'kb'; // Quick fix.
        }
        return $abbr_bytes.' '.$abbr;
    }
public function bytesAbbr(float $bytes, int $precision = 2): string
    {
        $bytes      = max(0, (int) $bytes);
        $precision  = max(0, $precision);

        $units      = ['bytes', 'kbs', 'MB', 'GB', 'TB'];
        $power      = floor(($bytes ? log($bytes) : 0) / log(1024));
        $abbr_bytes = round($bytes / pow(1024, $power), $precision);
        $abbr       = $units[min($power, count($units) - 1)];

        if ($abbr_bytes === (float) 1 && $abbr === 'bytes') {
            $abbr = 'byte'; // Quick fix.
        } elseif ($abbr_bytes === (float) 1 && $abbr === 'kbs') {
            $abbr = 'kb'; // Quick fix.
        }
        return $abbr_bytes.' '.$abbr;
    }
Abbreviated byte notation.

@since 150424 Initial release.

@param int|float $bytes File size in bytes.
@note This accepts `float` for back compat. only.

@param int $precision Number of decimals to use.

@return string Abbreviated byte notation.