@param int $bytes
@param int $decimals

@return string
196553
public static function convertToHumanReadable($bytes, $decimals = 2)
    {
        $factor = floor((strlen($bytes) - 1) / 3);

        $value = sprintf("%.{$decimals}f", $bytes / pow(1024, $factor));
        $unit = static::$sizes[(string)$factor];

        return sprintf('%g %s', $value, $unit);
    }
932525
public static function decimal( $value, $decimals = 2 )
	{
		$nf = new \NumberFormatter(\Locale::getDefault(), \NumberFormatter::DECIMAL);
		$nf->setAttribute(\NumberFormatter::MAX_FRACTION_DIGITS, $decimals);
		return $nf->format($value);
	}
1358072
private function getCodePoint($bytes)
    {
        if (\strlen($bytes) === 2) {
            return ((\ord($bytes[0]) & 0b11111) << 6)
                | (\ord($bytes[1]) & 0b111111);
        }

        if (\strlen($bytes) === 3) {
            return ((\ord($bytes[0]) & 0b1111) << 12)
                | ((\ord($bytes[1]) & 0b111111) << 6)
                | (\ord($bytes[2]) & 0b111111);
        }

        return ((\ord($bytes[0]) & 0b111) << 18)
            | ((\ord($bytes[1]) & 0b111111) << 12)
            | ((\ord($bytes[2]) & 0b111111) << 6)
            | (\ord($bytes[3]) & 0b111111);
    }
661660
public static function toHexadecimal(string $bytes): string
	{
		if(strlen($bytes) !== 16)
		{
			throw new InvalidArgumentException('The input must be exactly 16 bytes.');
		}

		return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($bytes), 4));
	}
782530
public static function number($number, $decimals = 0)
    {
        $l = self::getLocale();
        return number_format($number, $decimals, $l->decimalPoint, $l->thousandsSep);
    }
619162
public static function humanize(
        $bytes,
        int $decimals = 2,
        array $sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
    ): string
    {
        $power = 0;
        $temp = $bytes;
        $count = (count($sizes) - 1);
        for ($i = 0; $i < $count; $i++) {
            if ($temp < 1024) {
                break;
            } else {
                $temp /= 1024;
                $power++;
            }
        }

        $humanize = sprintf("%.{$decimals}f", ($bytes / pow(1024, $power))) . $sizes[$power];

        return $humanize;
    }
1059367
protected function formatBytes($bytes): string
    {
        $suffix = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];

        $p = min((int)log($bytes, 1024), count($suffix) - 1);

        return sprintf('%1.2f%s', ($bytes / pow(1024, $p)), $suffix[$p]);
    }
1040930
public function number($number, $decimals = 0)
    {
        return number_format(
            (float) $number,
            $decimals,
            $this->get('number')['decimal_separator'],
            $this->get('number')['thousands_separator']
        );
    }
663707
private static function sizeFormat($bytes)
    {
        $kb = 1024;
        $mb = $kb * 1024;
        $gb = $mb * 1024;
        $tb = $gb * 1024;

        if (($bytes >= 0) && ($bytes < $kb)) {
            return $bytes . ' B';
        } elseif (($bytes >= $kb) && ($bytes < $mb)) {
            return ceil($bytes / $kb) . ' KB';
        } elseif (($bytes >= $mb) && ($bytes < $gb)) {
            return ceil($bytes / $mb) . ' MB';
        } elseif (($bytes >= $gb) && ($bytes < $tb)) {
            return ceil($bytes / $gb) . ' GB';
        } elseif ($bytes >= $tb) {
            return ceil($bytes / $tb) . ' TB';
        } else {
            return $bytes . ' B';
        }
    }
590760
public function getStringByByte($bytes, $decimals = 2, $decimalPoint = '.', $thousandsSeparator = ',')
    {
        $size = [
            'B',
            'kB',
            'MB',
            'GB',
            'TB',
            'PB',
            'EB',
            'ZB',
            'YB',
        ];

        $factor = intval(floor((strlen($bytes) - 1) / 3));
        if (false === isset($size[$factor])) {
            return $bytes;
        }

        return sprintf('%s %s', number_format($bytes / pow(1024, $factor), $decimals, $decimalPoint, $thousandsSeparator), $size[$factor]);
    }
884341
protected function getReadableBytes($bytes, $precision)
    {
        $suffix = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
        $total = count($suffix);

        for ($i = 0; $bytes > 1024 && $i < $total; $i++) {
            $bytes /= 1024;
        }

        return number_format($bytes, $precision) . ' ' . $suffix[$i];
    }
933918
public static function byteStringToInt($bytes)
    {
        if (!self::isSupported()) {
            throw new \RuntimeException('This utility is only supported on 64 bit machines with PHP version > 5.5.');
        }
        if (self::isSystemLittleEndian()) {
            $bytes = strrev($bytes);
        }
        return unpack("q", $bytes)[1];
    }
57516
public function show_bytes($bytes, &$unit = null)
    {
        if ($bytes >= 1073741824) {
            $unit = 'GB';
            $gb   = $bytes/1073741824;
            $str  = sprintf($gb >= 10 ? "%d " : "%.1f ", $gb) . $this->gettext($unit);
        }
        else if ($bytes >= 1048576) {
            $unit = 'MB';
            $mb   = $bytes/1048576;
            $str  = sprintf($mb >= 10 ? "%d " : "%.1f ", $mb) . $this->gettext($unit);
        }
        else if ($bytes >= 1024) {
            $unit = 'KB';
            $str  = sprintf("%d ",  round($bytes/1024)) . $this->gettext($unit);
        }
        else {
            $unit = 'B';
            $str  = sprintf('%d ', $bytes) . $this->gettext($unit);
        }

        return $str;
    }
979379
public static function format($value, int $decimals = 2): ?string {
        if (!\is_numeric($value)) {
            return null;
        }
        return \number_format($value, $decimals);
    }
1232829
private function formatSize($bytes)
    {
        $units = ['B', 'KB', 'MB', 'GB', 'TB'];

        $bytes = max($bytes, 0);
        $pow = $bytes ? floor(log($bytes, 1024)) : 0;
        $pow = min($pow, count($units) - 1);

        $bytes /= pow(1024, $pow);

        return number_format($bytes, 2).' '.$units[$pow];
    }
309949
public static function numberFormat($number, $decimals = 0)
    {
        return is_numeric($number) ? number_format(
            $number,
            $decimals,
            __('lang_decimal_point'),
            __('lang_thousands_sep')
        ) : $number;
    }
1331346
public function toFixed($decimals = 2) {

		if(false === ('-' . intval($decimals) == '-' . $decimals)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type integer, "%s" given', __METHOD__, gettype($decimals)), E_USER_ERROR);
		}

		return $this -> convert(function($number, $decimals) {
			
			$split = explode('.', (string) $number);

			if(count($split) < 2) {
				$split[1] = str_repeat('0', $decimals);
			}

			if(strlen($split[1]) < $decimals) {
				$split[1] .= str_repeat('0', $decimals - strlen($split[1]));
			}

			return rtrim(rtrim($split[0] . '.' . substr($split[1], 0, $decimals), ','), '.');

		}, [$decimals]);
	}