<commit_before><?php

namespace ActiveResource\Errors;
use ActiveResource\Ext\Inflector;

/**
 * Entity validation errors holder
 */
class Errors
{
    protected $class;
    protected $messages = array();

    public function __construct($class)
    {
        $this->class = $class;
    }

    /**
     * Clear all messages
     */
    public function clear()
    {
        $this->messages = array();
    }

    /**
     * Add message to the error messages on attribute
     *
     * @param string $key
     * @param string $value
     */
    public function add($key, $value)
    {
        $this->messages[$key][] = (string)$value;
    }

    /**
     * Set messages for key to value
     *
     * @param string $key
     * @param mixed $value string or array of strings
     */
    public function set($key, $value)
    {
        $this->messages[$key] = is_array($value) ? $value : array($value);
    }

    /**
     * Get messages for key
     *
     * @param string $key
     * @return array
     */
    public function get($key)
    {
        if (isset($this->messages[$key]))
        {
            return $this->messages[$key];
        }<commit_msg>allow errors to be array<commit_after><?php

namespace ActiveResource\Errors;
use ActiveResource\Ext\Inflector;

/**
 * Entity validation errors holder
 */
class Errors
{
    protected $class;
    protected $messages = array();

    public function __construct($class)
    {
        $this->class = $class;
    }

    /**
     * Clear all messages
     */
    public function clear()
    {
        $this->messages = array();
    }

    /**
     * Add message to the error messages on attribute
     *
     * @param string $key
     * @param string $value
     */
    public function add($key, $value)
    {
        if (!is_array($value)) {
            $value = array($value);
        }
        foreach ($value as $item) {
            $this->messages[$key][] = (string)$item;
        }
    }

    /**
     * Set messages for key to value
     *
     * @param string $key
     * @param mixed $value string or array of strings
     */
    public function set($key, $value)
    {
        $this->messages[$key] = is_array($value) ? $value : array($value);
    }

    /**
     * Get messages for key
     *
     * @param string $key
     * @return array
     */
    public function get($key)
    {
        if (isset($this->messages[$key]))
        {
            return $this->messages[$key];
        }
{'fraction_non_alphanumeric': 0.13638219681502653, 'fraction_numerical': 0.0, 'mean_word_length': 1.875586854460094, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, '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': '6702619', 'n_tokens_mistral': 719, 'n_tokens_neox': 711, 'n_words': 192}