<commit_before><?php
/**
 * This file is part of Knit package.
 * https://github.com/comelyio/knit
 *
 *  Copyright (c) 2018 <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code or visit following link:
 * https://github.com/comelyio/knit/blob/master/LICENSE
 */

declare(strict_types=1);

namespace Comely\Knit\Compiler\Parser;

use Comely\Knit\Exception\ParseException;

/**
 * Class Variables
 * @package Comely\Knit\Compiler\Parser
 */
class Variables
{
    /** @var array */
    private $vars;

    /**
     * Variables constructor.
     */
    public function __construct()
    {
        $this->vars = [];
    }

    /**
     * @param string $var
     */
    public function add(string $var): void
    {
        if (in_array(strtolower($var), ["this", "knit"])) {
            throw new ParseException(sprintf('Variable "%s" cannot be reserved', $var));
        }

        $this->vars[] = $var;
    }

    /**
     * @param string $var
     */
    public function delete(string $var): void
    {
        $index = array_search($var, $this->vars);
        if ($index !== false) {
            unset($this->vars[$index]);
        }
    }

    /**
     * @param string $var
     * @return bool
     */
    public function has(string $var): bool
    {
        return in_array($var, $this->vars);
    }
}<commit_msg>change exception in add() method<commit_after><?php
/**
 * This file is part of Knit package.
 * https://github.com/comelyio/knit
 *
 *  Copyright (c) 2018 <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code or visit following link:
 * https://github.com/comelyio/knit/blob/master/LICENSE
 */

declare(strict_types=1);

namespace Comely\Knit\Compiler\Parser;

/**
 * Class Variables
 * @package Comely\Knit\Compiler\Parser
 */
class Variables
{
    /** @var array */
    private $vars;

    /**
     * Variables constructor.
     */
    public function __construct()
    {
        $this->vars = [];
    }

    /**
     * @param string $var
     */
    public function add(string $var): void
    {
        if (in_array(strtolower($var), ["this", "knit"])) {
            throw new \DomainException(sprintf('Variable "%s" cannot be reserved', $var));
        }

        $this->vars[] = $var;
    }

    /**
     * @param string $var
     */
    public function delete(string $var): void
    {
        $index = array_search($var, $this->vars);
        if ($index !== false) {
            unset($this->vars[$index]);
        }
    }

    /**
     * @param string $var
     * @return bool
     */
    public function has(string $var): bool
    {
        return in_array($var, $this->vars);
    }
}
{'fraction_non_alphanumeric': 0.15078796561604585, 'fraction_numerical': 0.0035816618911174787, 'mean_word_length': 2.278169014084507, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 19, 'https://': 4, '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': '4871691', 'n_tokens_mistral': 871, 'n_tokens_neox': 849, 'n_words': 222}