src/mako/utility/Humanizer.php
public function fileSize($size, bool $binary = true): string
	{
		if($size > 0)
		{
			if($binary === true)
			{
				$base  = 1024;
				$terms = ['byte', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'];
			}
			else
			{
				$base  = 1000;
				$terms = ['byte', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
			}

			$e = floor(log($size, $base));

			return round($size / ($base ** $e), 2) . ' ' . $terms[$e];
		}

		return '0 byte';
	}
public function fileSize($size, bool $binary = true): string
	{
		if($size > 0)
		{
			if($binary === true)
			{
				$base  = 1024;
				$terms = ['byte', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'];
			}
			else
			{
				$base  = 1000;
				$terms = ['byte', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
			}

			$e = floor(log($size, $base));

			return round($size / ($base ** $e), 2) . ' ' . $terms[$e];
		}

		return '0 byte';
	}
public function fileSize ( $ size , bool $ binary = true ) : string { if ( $ size > 0 ) { if ( $ binary === true ) { $ base = 1024 ; $ terms = [ 'byte' , 'KiB' , 'MiB' , 'GiB' , 'TiB' , 'PiB' , 'EiB' , 'ZiB' , 'YiB' ] ; } else { $ base = 1000 ; $ terms = [ 'byte' , 'KB' , 'MB' , 'GB' , 'TB' , 'PB' , 'EB' , 'ZB' , 'YB' ] ; } $ e = floor ( log ( $ size , $ base ) ) ; return round ( $ size / ( $ base ** $ e ) , 2 ) . ' ' . $ terms [ $ e ] ; } return '0 byte' ; }
Returns a human friendly file size.

@param  int    $size   File size in bytes
@param  bool   $binary True to use binary suffixes and false to use decimal suffixes
@return string
Returns a human friendly file size .