public function format($bytes, $precision = null)
    {
        // Use default precision when not specified.
        $precision === null && $precision = $this->getPrecision();

        $log = log($bytes, $this->getBase());
        $exponent = $this->hasFixedExponent() ? $this->getFixedExponent() : max(0, $log|0);
        $value = round(pow($this->getBase(), $log - $exponent), $precision);
        $units = $this->getUnitDecorator()->decorate($exponent, $this->getBase(), $value);

        return trim(sprintf($this->sprintfFormat, $this->formatValue($value, $precision), $units));
    }
public function format($bytes, $precision = null)
    {
        // Use default precision when not specified.
        $precision === null && $precision = $this->getPrecision();

        $log = log($bytes, $this->getBase());
        $exponent = $this->hasFixedExponent() ? $this->getFixedExponent() : max(0, $log|0);
        $value = round(pow($this->getBase(), $log - $exponent), $precision);
        $units = $this->getUnitDecorator()->decorate($exponent, $this->getBase(), $value);

        return trim(sprintf($this->sprintfFormat, $this->formatValue($value, $precision), $units));
    }
public function format ( $ bytes , $ precision = null ) { // Use default precision when not specified. $ precision === null && $ precision = $ this -> getPrecision ( ) ; $ log = log ( $ bytes , $ this -> getBase ( ) ) ; $ exponent = $ this -> hasFixedExponent ( ) ? $ this -> getFixedExponent ( ) : max ( 0 , $ log | 0 ) ; $ value = round ( pow ( $ this -> getBase ( ) , $ log - $ exponent ) , $ precision ) ; $ units = $ this -> getUnitDecorator ( ) -> decorate ( $ exponent , $ this -> getBase ( ) , $ value ) ; return trim ( sprintf ( $ this -> sprintfFormat , $ this -> formatValue ( $ value , $ precision ) , $ units ) ) ; }
Formats the specified number of bytes as a human-readable string.

@param int $bytes Number of bytes.
@param int|null $precision Optional. Number of fractional digits.

@return string Formatted bytes.
Formats the specified number of bytes as a human - readable string .