<commit_before><?php

namespace Jasny;

/**
 * Validation result
 */
class ValidationResult
{
    /**
     * @var array
     */
    protected $errors = [];
    
    /**
     * Add an error
     * 
     * @param string $message
     */
    public function addError($message)
    {
        $this->errors[] = $message;
    }
    
    /**
     * Add errors from a validation object
     * 
     * @param Validation $validation
     * @param string     $prefix
     */<commit_msg>Added method for translating messages<commit_after><?php

namespace Jasny;

/**
 * Validation result
 */
class ValidationResult
{
    /**
     * Callback for translating the error message
     * @var callback
     */
    public static $translate;
    
    
    /**
     * @var array
     */
    protected $errors = [];

    
    /**
     * Add an error
     * 
     * @param string $message
     * @param mixed  ...       Arguments to insert into the message
     */
    public function addError($message)
    {
        if (isset(static::$translate)) $message = call_user_func(static::$translate, $message);
        
        if (func_num_args() > 1) {
            $args = [0 => $message] + func_get_args();
            $message = call_user_func_array('sprintf', $args);
        }
        
        $this->errors[] = $message;
    }
    
    /**
     * Add errors from a validation object
     * 
     * @param Validation $validation
     * @param string     $prefix
     */
{'fraction_non_alphanumeric': 0.12508638562543192, 'fraction_numerical': 0.00138217000691085, 'mean_word_length': 1.7739463601532568, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1172322', 'n_tokens_mistral': 427, 'n_tokens_neox': 416, 'n_words': 106}