public static function convertUnitFileSize($size)
    {
        $units = [" B", " KB", " MB", " GB"];
        $calculatedSize = $size;
        $unit = Arrays::first($units);
        if ($size) {
            $calculatedSize = round($size / pow(1024, ($i = (int)floor(log($size, 1024)))), 2);
            $unit = $units[$i];
        }
        return $calculatedSize . $unit;
    }
public static function convertUnitFileSize($size)
    {
        $units = [" B", " KB", " MB", " GB"];
        $calculatedSize = $size;
        $unit = Arrays::first($units);
        if ($size) {
            $calculatedSize = round($size / pow(1024, ($i = (int)floor(log($size, 1024)))), 2);
            $unit = $units[$i];
        }
        return $calculatedSize . $unit;
    }
public static function convertUnitFileSize ( $ size ) { $ units = [ " B" , " KB" , " MB" , " GB" ] ; $ calculatedSize = $ size ; $ unit = Arrays :: first ( $ units ) ; if ( $ size ) { $ calculatedSize = round ( $ size / pow ( 1024 , ( $ i = ( int ) floor ( log ( $ size , 1024 ) ) ) ) , 2 ) ; $ unit = $ units [ $ i ] ; } return $ calculatedSize . $ unit ; }
Converts file size in bytes to a string with unit.

Example:
<code>
$unit = Files::convertUnitFileSize(146432);
</code>
Result:
<code>
143 KB
</code>

@param int $size
@return string
Converts file size in bytes to a string with unit .