framework/i18n/Formatter.php
protected function asPercentStringFallback($value, $decimals = null)
    {
        if (empty($value)) {
            $value = 0;
        }

        if ($decimals === null) {
            $decimals = 0;
        }

        $value = $this->normalizeNumericStringValue((string) $value);
        $separatorPosition = strrpos($value, '.');

        if ($separatorPosition !== false) {
            $integerPart = substr($value, 0, $separatorPosition);
            $fractionalPart = str_pad(substr($value, $separatorPosition + 1), 2, '0');

            $integerPart .= substr($fractionalPart, 0, 2);
            $fractionalPart = substr($fractionalPart, 2);

            if ($fractionalPart === '') {
                $multipliedValue = $integerPart;
            } else {
                $multipliedValue = $integerPart . '.' . $fractionalPart;
            }
        } else {
            $multipliedValue = $value . '00';
        }

        return $this->asDecimalStringFallback($multipliedValue, $decimals) . '%';
    }
protected function asPercentStringFallback($value, $decimals = null)
    {
        if (empty($value)) {
            $value = 0;
        }

        if ($decimals === null) {
            $decimals = 0;
        }

        $value = $this->normalizeNumericStringValue((string) $value);
        $separatorPosition = strrpos($value, '.');

        if ($separatorPosition !== false) {
            $integerPart = substr($value, 0, $separatorPosition);
            $fractionalPart = str_pad(substr($value, $separatorPosition + 1), 2, '0');

            $integerPart .= substr($fractionalPart, 0, 2);
            $fractionalPart = substr($fractionalPart, 2);

            if ($fractionalPart === '') {
                $multipliedValue = $integerPart;
            } else {
                $multipliedValue = $integerPart . '.' . $fractionalPart;
            }
        } else {
            $multipliedValue = $value . '00';
        }

        return $this->asDecimalStringFallback($multipliedValue, $decimals) . '%';
    }
protected function asPercentStringFallback ( $ value , $ decimals = null ) { if ( empty ( $ value ) ) { $ value = 0 ; } if ( $ decimals === null ) { $ decimals = 0 ; } $ value = $ this -> normalizeNumericStringValue ( ( string ) $ value ) ; $ separatorPosition = strrpos ( $ value , '.' ) ; if ( $ separatorPosition !== false ) { $ integerPart = substr ( $ value , 0 , $ separatorPosition ) ; $ fractionalPart = str_pad ( substr ( $ value , $ separatorPosition + 1 ) , 2 , '0' ) ; $ integerPart .= substr ( $ fractionalPart , 0 , 2 ) ; $ fractionalPart = substr ( $ fractionalPart , 2 ) ; if ( $ fractionalPart === '' ) { $ multipliedValue = $ integerPart ; } else { $ multipliedValue = $ integerPart . '.' . $ fractionalPart ; } } else { $ multipliedValue = $ value . '00' ; } return $ this -> asDecimalStringFallback ( $ multipliedValue , $ decimals ) . '%' ; }
Fallback for formatting value as a percent number with "%" sign.

Property [[decimalSeparator]] will be used to represent the decimal point. The value is rounded automatically
to the defined decimal digits.

@param string|int|float $value the value to be formatted.
@param int $decimals the number of digits after the decimal point. The default value is `0`.
@return string the formatted result.
@since 2.0.16
Fallback for formatting value as a percent number with % sign .