<commit_before><?php namespace SCT;

/**
 * Class Template
 * Super simple templating engine
 *
 * @package SCT
 */
class TemplateEngine
{
    private $vars = [];
    private $templatePath;

    public function __construct(string $templatePath)
    {
        $this->templatePath = realpath($templatePath);
    }

    public function __get(string $name)
    {
        return $this->vars[ $name ];
    }

    public function __set(string $name, string $value)
    {
        if ($name == 'view_template_file')
        {
            throw new \Exception("Cannot bind variable named 'view_template_file'");
        }

        $this->vars[ $name ] = $value;
    }

    /**
     * @param string $view_template_file The name of the template file
     * @param array $vars
     *
     * @return mixed
     * @throws \Exception
     */
    public function render(string $view_template_file, array $vars = [])
    {
        $this->vars = array_merge($this->vars, $vars);

        if (array_key_exists('view_template_file', $this->vars))
        {
            throw new \Exception("Cannot bind variable called 'view_template_file'");
        }

        extract($this->vars);
        ob_start();

        /** @noinspection PhpIncludeInspection */
        include($this->templatePath . "/$view_template_file");

        return ob_get_clean();
    }
}<commit_msg>cant do type hinting needs to allow null<commit_after><?php namespace SCT;

/**
 * Class Template
 * Super simple templating engine
 *
 * @package SCT
 */
class TemplateEngine
{
    private $vars = [];
    private $templatePath;

    public function __construct(string $templatePath)
    {
        $this->templatePath = realpath($templatePath);
    }

    public function __get(string $name)
    {
        return $this->vars[ $name ];
    }

    public function __set(string $name, string $value)
    {
        if ($name == 'view_template_file')
        {
            throw new \Exception("Cannot bind variable named 'view_template_file'");
        }

        $this->vars[ $name ] = $value;
    }

    /**
     * @param string $view_template_file The name of the template file
     * @param array $vars could be null
     *
     * @return mixed
     * @throws \Exception
     */
    public function render(string $view_template_file, $vars = [])
    {
        if ($vars)
        {
            $this->vars = array_merge($this->vars, $vars);
        }

        if (array_key_exists('view_template_file', $this->vars))
        {
            throw new \Exception("Cannot bind variable called 'view_template_file'");
        }

        extract($this->vars);
        ob_start();

        /** @noinspection PhpIncludeInspection */
        include($this->templatePath . "/$view_template_file");

        return ob_get_clean();
    }
}
{'fraction_non_alphanumeric': 0.1250901225666907, 'fraction_numerical': 0.0, 'mean_word_length': 2.3035714285714284, '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': '5365436', 'n_tokens_mistral': 810, 'n_tokens_neox': 794, 'n_words': 195}