Swat/exceptions/SwatException.php
protected function formatValue($value)
    {
        $formatted_value = '<unknown parameter type>';

        if (is_object($value)) {
            $formatted_value = '<' . get_class($value) . ' object>';
        } elseif ($value === null) {
            $formatted_value = '<null>';
        } elseif (is_string($value)) {
            if (SwatString::validateUtf8($value)) {
                $formatted_value = "'" . $value . "'";
            } else {
                $formatted_value = '"' . SwatString::escapeBinary($value) . '"';
            }
        } elseif (is_int($value) || is_float($value)) {
            $formatted_value = strval($value);
        } elseif (is_bool($value)) {
            $formatted_value = $value ? 'true' : 'false';
        } elseif (is_resource($value)) {
            $formatted_value = '<resource>';
        } elseif (is_array($value)) {
            // check whether or not array is associative
            $keys = array_keys($value);
            $associative = false;
            $count = 0;
            foreach ($keys as $key) {
                if ($key !== $count) {
                    $associative = true;
                    break;
                }
                $count++;
            }

            $formatted_value = 'array(';

            $count = 0;
            foreach ($value as $key => $the_value) {
                if ($count > 0) {
                    $formatted_value .= ', ';
                }

                if ($associative) {
                    $formatted_value .= $this->formatValue($key);
                    $formatted_value .= ' => ';
                }
                $formatted_value .= $this->formatValue($the_value);
                $count++;
            }
            $formatted_value .= ')';
        }

        return $formatted_value;
    }
protected function formatValue($value)
    {
        $formatted_value = '<unknown parameter type>';

        if (is_object($value)) {
            $formatted_value = '<' . get_class($value) . ' object>';
        } elseif ($value === null) {
            $formatted_value = '<null>';
        } elseif (is_string($value)) {
            if (SwatString::validateUtf8($value)) {
                $formatted_value = "'" . $value . "'";
            } else {
                $formatted_value = '"' . SwatString::escapeBinary($value) . '"';
            }
        } elseif (is_int($value) || is_float($value)) {
            $formatted_value = strval($value);
        } elseif (is_bool($value)) {
            $formatted_value = $value ? 'true' : 'false';
        } elseif (is_resource($value)) {
            $formatted_value = '<resource>';
        } elseif (is_array($value)) {
            // check whether or not array is associative
            $keys = array_keys($value);
            $associative = false;
            $count = 0;
            foreach ($keys as $key) {
                if ($key !== $count) {
                    $associative = true;
                    break;
                }
                $count++;
            }

            $formatted_value = 'array(';

            $count = 0;
            foreach ($value as $key => $the_value) {
                if ($count > 0) {
                    $formatted_value .= ', ';
                }

                if ($associative) {
                    $formatted_value .= $this->formatValue($key);
                    $formatted_value .= ' => ';
                }
                $formatted_value .= $this->formatValue($the_value);
                $count++;
            }
            $formatted_value .= ')';
        }

        return $formatted_value;
    }
protected function formatValue ( $ value ) { $ formatted_value = '<unknown parameter type>' ; if ( is_object ( $ value ) ) { $ formatted_value = '<' . get_class ( $ value ) . ' object>' ; } elseif ( $ value === null ) { $ formatted_value = '<null>' ; } elseif ( is_string ( $ value ) ) { if ( SwatString :: validateUtf8 ( $ value ) ) { $ formatted_value = "'" . $ value . "'" ; } else { $ formatted_value = '"' . SwatString :: escapeBinary ( $ value ) . '"' ; } } elseif ( is_int ( $ value ) || is_float ( $ value ) ) { $ formatted_value = strval ( $ value ) ; } elseif ( is_bool ( $ value ) ) { $ formatted_value = $ value ? 'true' : 'false' ; } elseif ( is_resource ( $ value ) ) { $ formatted_value = '<resource>' ; } elseif ( is_array ( $ value ) ) { // check whether or not array is associative $ keys = array_keys ( $ value ) ; $ associative = false ; $ count = 0 ; foreach ( $ keys as $ key ) { if ( $ key !== $ count ) { $ associative = true ; break ; } $ count ++ ; } $ formatted_value = 'array(' ; $ count = 0 ; foreach ( $ value as $ key => $ the_value ) { if ( $ count > 0 ) { $ formatted_value .= ', ' ; } if ( $ associative ) { $ formatted_value .= $ this -> formatValue ( $ key ) ; $ formatted_value .= ' => ' ; } $ formatted_value .= $ this -> formatValue ( $ the_value ) ; $ count ++ ; } $ formatted_value .= ')' ; } return $ formatted_value ; }
Formats a parameter value for display in a stack trace

@param mixed $value the value of the parameter.

@return string the formatted version of the parameter.
Formats a parameter value for display in a stack trace