<commit_before><?php

namespace Dan\Database\Traits;

use Illuminate\Support\Arr;

trait Data
{
    /**
     * @var array
     */
    protected $data = [];

    /**
     * @param $key
     *
     * @return bool
     */
    public function hasData($key)
    {
        return Arr::has($this->data, $key);
    }

    /**
     * @param $key
     * @param $value
     *
     * @return $this
     */
    public function setData($key, $value = null)
    {
        if ($value === null) {
            $this->data = $key;

            return $this;
        }

        Arr::set($this->data, $key, $value);

        return $this;
    }

    /**
     * @param $key
     * @param null $default
     *
     * @return mixed
     */
    public function getData($key, $default = null)
    {
        return Arr::get($this->data, $key, $default);
    }

    /**
     * @param $key
     * @param $value
     *
     * @return $this
     */
    public function putData($key, $value)
    {
        $current = $this->getData($key, []);
        $current[] = $value;
        $this->setData($key, $current);

        return $this;
    }

    /**
     * @param $key
     * @param $value
     *
     * @return $this
     */
    public function forgetData($key, $value)
    {
        $current = $this->getData($key, []);

        foreach ($current as $k => $item) {
            if ($item == $value) {
                unset($current[$k]);
            }
        }

        $this->setData($key, array_values($current));

        return $this;
    }

    /**
     * @param $key
     *
     * @return $this
     */
    public function forgetDataByKey($key)
    {
        Arr::forget($this->data, $key);

        return $this;
    }
}
<commit_msg>Let's see if this can help figure out what's causing data errors.<commit_after><?php

namespace Dan\Database\Traits;

use Illuminate\Support\Arr;

trait Data
{
    /**
     * @var array
     */
    protected $data = [];

    /**
     * @param $key
     *
     * @return bool
     */
    public function hasData($key)
    {
        return Arr::has($this->data, $key);
    }

    /**
     * @param $key
     * @param $value
     *
     * @throws \Exception
     *
     * @return $this
     */
    public function setData($key, $value = null)
    {
        if ($value === null) {
            if(!is_array($key)) {
                throw new \Exception('Value must be an array');
            }

            $this->data = $key;

            return $this;
        }

        Arr::set($this->data, $key, $value);

        return $this;
    }

    /**
     * @param $key
     * @param null $default
     *
     * @return mixed
     */
    public function getData($key, $default = null)
    {
        return Arr::get($this->data, $key, $default);
    }

    /**
     * @param $key
     * @param $value
     *
     * @return $this
     */
    public function putData($key, $value)
    {
        $current = $this->getData($key, []);
        $current[] = $value;
        $this->setData($key, $current);

        return $this;
    }

    /**
     * @param $key
     * @param $value
     *
     * @return $this
     */
    public function forgetData($key, $value)
    {
        $current = $this->getData($key, []);

        foreach ($current as $k => $item) {
            if ($item == $value) {
                unset($current[$k]);
            }
        }

        $this->setData($key, array_values($current));

        return $this;
    }

    /**
     * @param $key
     *
     * @return $this
     */
    public function forgetDataByKey($key)
    {
        Arr::forget($this->data, $key);

        return $this;
    }
}

{'fraction_non_alphanumeric': 0.16556108347153123, 'fraction_numerical': 0.0, 'mean_word_length': 1.5062326869806095, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, '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': '333693', 'n_tokens_mistral': 1175, 'n_tokens_neox': 1158, 'n_words': 249}