src/mako/validator/rules/file/MaxFilesize.php
protected function convertToBytes($size)
	{
		if(is_numeric($unit = substr($size, -3)) === false)
		{
			$size = substr($size, 0, -3);

			switch($unit)
			{
				case 'KiB':
					return $size * 1024;
				case 'MiB':
					return $size * (1024 ** 2);
				case 'GiB':
					return $size * (1024 ** 3);
				case 'TiB':
					return $size * (1024 ** 4);
				case 'PiB':
					return $size * (1024 ** 5);
				case 'EiB':
					return $size * (1024 ** 6);
				case 'ZiB':
					return $size * (1024 ** 7);
				case 'YiB':
					return $size * (1024 ** 8);
				default:
					throw new RuntimeException(vsprintf('Invalid unit type [ %s ].', [$unit]));
			}
		}

		return (int) $size;
	}
protected function convertToBytes($size)
	{
		if(is_numeric($unit = substr($size, -3)) === false)
		{
			$size = substr($size, 0, -3);

			switch($unit)
			{
				case 'KiB':
					return $size * 1024;
				case 'MiB':
					return $size * (1024 ** 2);
				case 'GiB':
					return $size * (1024 ** 3);
				case 'TiB':
					return $size * (1024 ** 4);
				case 'PiB':
					return $size * (1024 ** 5);
				case 'EiB':
					return $size * (1024 ** 6);
				case 'ZiB':
					return $size * (1024 ** 7);
				case 'YiB':
					return $size * (1024 ** 8);
				default:
					throw new RuntimeException(vsprintf('Invalid unit type [ %s ].', [$unit]));
			}
		}

		return (int) $size;
	}
protected function convertToBytes ( $ size ) { if ( is_numeric ( $ unit = substr ( $ size , - 3 ) ) === false ) { $ size = substr ( $ size , 0 , - 3 ) ; switch ( $ unit ) { case 'KiB' : return $ size * 1024 ; case 'MiB' : return $ size * ( 1024 ** 2 ) ; case 'GiB' : return $ size * ( 1024 ** 3 ) ; case 'TiB' : return $ size * ( 1024 ** 4 ) ; case 'PiB' : return $ size * ( 1024 ** 5 ) ; case 'EiB' : return $ size * ( 1024 ** 6 ) ; case 'ZiB' : return $ size * ( 1024 ** 7 ) ; case 'YiB' : return $ size * ( 1024 ** 8 ) ; default : throw new RuntimeException ( vsprintf ( 'Invalid unit type [ %s ].' , [ $ unit ] ) ) ; } } return ( int ) $ size ; }
Convert human friendly size to bytes.

@param  int|string        $size Size
@throws \RuntimeException
@return int|float
Convert human friendly size to bytes .