protected function createMessageFromTemplate($messageTemplate, $value)
    {
        // AbstractValidator::translateMessage does not use first argument.
        $message = $this->translateMessage('dummyValue',
                                           (string) $messageTemplate);
    
        if (is_object($value) &&
                        !in_array('__toString', get_class_methods($value))
        ) {
            $value = get_class($value) . ' object';
        } elseif (is_array($value)) {
            $value = var_export($value, 1);
        } else {
            $value = (string) $value;
        }
    
        if ($this->isValueObscured()) {
            $value = str_repeat('*', strlen($value));
        }
    
        $message = str_replace('%value%', (string) $value, $message);
        $message = str_replace('%count%', (string) $this->count(), $message);
    
        $length = self::getMessageLength();
        if (($length > -1) && (strlen($message) > $length)) {
            $message = substr($message, 0, ($length - 3)) . '...';
        }
    
        return $message;
    }