<commit_before><?php

namespace WP_Migrations\OptionVersions\Repositories;


class OptionScriptRepository
{
    const OPTION_NAME = "wp-migrations-option-scripts";

    private $options;

    public function __construct()
    {
        $optionValues  = get_option(self::OPTION_NAME);
        $this->options = $optionValues ?: [];
    }

    /**
     * Create the plugin options repository data store.
     *
     * @return void
     */
    public static function createRepository()
    {
        add_option(self::OPTION_NAME, []);
    }

    /**
     * @return array
     */
    public function getOptions()
    {
        return $this->options;
    }

    /**
     * Register a option's owner
     *
     * @param  string $optionName
     * @param  object $object
     * @return void
     */
    public function cache($optionName, $object)
    {
        $options = $this->getOptions();
        if (!array_key_exists($optionName, $options)) {
            $this->options[$optionName] = $object;
        }
    }

    public function save()
    {
        update_option(self::OPTION_NAME, $this->options);
    }

    public function get($optionName)
    {
        $options = $this->getOptions();
        if (!array_key_exists($optionName, $options)) {
            return null;
        } else {
            return $options[$optionName];
        }
    }


}<commit_msg>don't store optionScriptModal namespace in database<commit_after><?php

namespace WP_Migrations\OptionVersions\Repositories;


class OptionScriptRepository
{
    const OPTION_NAME = "wp-migrations-option-scripts";

    private $options;

    public function __construct()
    {
        $optionValues  = get_option(self::OPTION_NAME);
        foreach ($optionValues as $option_name => $optionScriptData) {
            $optionScript = new OptionScriptModel();
            $optionScript->unserialize($optionScriptData);
            $options[$option_name] = $optionScript;
        }
        $this->options = $optionValues ?: [];
    }

    /**
     * Create the plugin options repository data store.
     *
     * @return void
     */
    public static function createRepository()
    {
        add_option(self::OPTION_NAME, []);
    }

    /**
     * @return array
     */
    public function getOptions()
    {
        return $this->options;
    }

    /**
     * Register a option's owner
     *
     * @param  string $optionName
     * @param  object $object
     * @return void
     */
    public function cache($optionName, $object)
    {
        $options = $this->getOptions();
        if (!array_key_exists($optionName, $options)) {
            $this->options[$optionName] = $object;
        }
    }

    public function save()
    {
        $options = [];
        foreach ($this->options as $option_name => $optionScript) {
            $options[$option_name] = $optionScript->serialize();
        }
        update_option(self::OPTION_NAME, $options);
    }

    public function get($optionName)
    {
        $options = $this->getOptions();
        if (!array_key_exists($optionName, $options)) {
            return null;
        } else {
            return $options[$optionName];
        }
    }


}
{'fraction_non_alphanumeric': 0.12503946952952322, 'fraction_numerical': 0.0, 'mean_word_length': 2.1553784860557768, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, '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': '3134789', 'n_tokens_mistral': 910, 'n_tokens_neox': 897, 'n_words': 182}