<commit_before><?php namespace MODX\Shell\Configuration;

/**
 * A configuration object storing all third party commands
 */
class Extension extends Base
{
    protected $path;

    public function __construct(array $items = array())
    {
        $this->path = $this->getConfigPath() . 'extraCommands.php';
        if (empty($items)) {
            $this->load($this->path);
        } else {
            $this->items = $items;
        }
    }

    public function get($key, $default = null)
    {
        $index = array_search($key, $this->items);
        if ($index !== false) {
            return $key;
        }

        return $default;
    }

    public function set($key, $value = null)
    {
        $index = array_search($key, $this->items);
        if ($index === false) {
            $this->items[] = $key;
        }
    }

    public function remove($key)
    {
        $index = array_search($key, $this->items);
        if ($index !== false) {
            unset($this->items[$index]);
        }
    }

    public function save()
    {
        $content = $this->formatData();
        $this->makeSureConfigPathExists();

        return file_put_contents($this->path, $content) !== false;
    }

    /**
     * Format the items so they could be stored as PHP array
     *
     * @return string
     */
    public function formatData()
    {
        $content = '<?php' . "\n\n"
                   .'return array(' ."\n";

        sort($this->items);
        foreach ($this->items as $c) {
            $content .= "    '{$c}',\n";
        }

        $content .= ');' ."\n";

        return $content;
    }

    public function load($path = null)
    {
        if (!$path) {
            $path = $this->path;
        }
        if (file_exists($path)) {
            $this->items = include_once $path;
        }
    }
}<commit_msg>Allow multiple extension configuration loading<commit_after><?php namespace MODX\Shell\Configuration;

/**
 * A configuration object storing all third party commands
 */
class Extension extends Base
{
    protected $path;

    public function __construct(array $items = array())
    {
        $this->path = $this->getConfigPath() . 'extraCommands.php';
        if (empty($items)) {
            $this->load($this->path);
        } else {
            $this->items = $items;
        }
    }

    public function get($key, $default = null)
    {
        $index = array_search($key, $this->items);
        if ($index !== false) {
            return $key;
        }

        return $default;
    }

    public function set($key, $value = null)
    {
        $index = array_search($key, $this->items);
        if ($index === false) {
            $this->items[] = $key;
        }
    }

    public function remove($key)
    {
        $index = array_search($key, $this->items);
        if ($index !== false) {
            unset($this->items[$index]);
        }
    }

    public function save()
    {
        $content = $this->formatData();
        $this->makeSureConfigPathExists();

        return file_put_contents($this->path, $content) !== false;
    }

    /**
     * Format the items so they could be stored as PHP array
     *
     * @return string
     */
    public function formatData()
    {
        $content = '<?php' . "\n\n"
                   .'return array(' ."\n";

        sort($this->items);
        foreach ($this->items as $c) {
            $content .= "    '{$c}',\n";
        }

        $content .= ');' ."\n";

        return $content;
    }

    public function load($path = null)
    {
        if (!$path) {
            $path = $this->path;
        }
        if (file_exists($path)) {
            $this->items = include $path;
        }
    }
}
{'fraction_non_alphanumeric': 0.1590909090909091, 'fraction_numerical': 0.0, 'mean_word_length': 1.6887272727272726, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 37, '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': '7297162', 'n_tokens_mistral': 1097, 'n_tokens_neox': 1073, 'n_words': 254}