<commit_before><?php

namespace ModelJsonColumn;

use Closure;

trait JsonColumnTrait
{
    /**
     * Holds the referenced json data.
     *
     * @var array
     */
    private $json_values = [];

    /**
     * Holds methods for accessing the json data.
     *
     * @var array
     */
    private $json_methods = [];

    /**
     * Holds default values for a json attribute.
     *
     * @var array
     */
    private $json_defaults = [];

    /**
     * Stores options for each JSON attribute.
     *
     * @var array
     */
    private $json_options = [];

    /**
     * Create a new model instance that is existing.
     * Overrides parent to set Json columns.
     *
     * @param array       $attributes
     * @param string|null $connection
     *
     * @return static
     */
    public function newFromBuilder($attributes = [], $connection = null)
    {
        $model = parent::newFromBuilder($attributes, $connection);
        $model->inspectJson();

        return $model;
    }

    /**
     * Decodes each of the declared JSON attributes and allocates them to
     * the json value object. Binds closures based on the column name to
     * access and update the values.
     *
     * @return void<commit_msg>Remove properties that can be defined in their own models<commit_after><?php

namespace ModelJsonColumn;

use Closure;

trait JsonColumnTrait
{
    /**
     * Holds the referenced json data.
     *
     * @var array
     */
    private $json_values = [];

    /**
     * Holds methods for accessing the json data.
     *
     * @var array
     */
    private $json_methods = [];

    /**
     * Holds default values for a json attribute.
     *
     * @var array
     */
    //private $json_defaults = [];

    /**
     * Stores options for each JSON attribute.
     *
     * @var array
     */
    //private $json_options = [];

    /**
     * Create a new model instance that is existing.
     * Overrides parent to set Json columns.
     *
     * @param array       $attributes
     * @param string|null $connection
     *
     * @return static
     */
    public function newFromBuilder($attributes = [], $connection = null)
    {
        $model = parent::newFromBuilder($attributes, $connection);
        $model->inspectJson();

        return $model;
    }

    /**
     * Decodes each of the declared JSON attributes and allocates them to
     * the json value object. Binds closures based on the column name to
     * access and update the values.
     *
     * @return void
{'fraction_non_alphanumeric': 0.10333863275039745, 'fraction_numerical': 0.0, 'mean_word_length': 1.975177304964539, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '479738', 'n_tokens_mistral': 712, 'n_tokens_neox': 695, 'n_words': 230}