<commit_before><?php declare(strict_types=1);
/**
 * HTML page template renderer
 *
 * PHP version 7.0
 *
 * @category   CodeCollab
 * @package    Template
 * @author     <NAME> <<EMAIL>>
 * @copyright  Copyright (c) 2015 <NAME> <https://github.com/PeeHaa>
 * @license    See the LICENSE file
 * @version    1.0.0
 */
namespace CodeCollab\Template;

/**
 * HTML page template renderer
 *
 * @category   CodeCollab
 * @package    Template
 * @author     <NAME> <<EMAIL>>
 */
class Html implements Renderer
{
    /**
     * @var array List of template variables
     */
    private $variables = [];

    /**
     * @var string The base (skeleton) page template
     */
    private $basePage;

    /**
     * Creates instance
     *
     * @param string $basePage The base (skeleton) page template
     */
    public function __construct(string $basePage)
    {
        $this->basePage = $basePage;
    }

    /**
     * Renders a template
     *
     * @param string $template The template to render
     * @param array  $data     The template variables
     *
     * @return string The rendered template
     */
    public function render(string $template, array $data = []): string
    {
        if (!empty($data)) {
            $this->variables = $data;
        }

        $output = '';

        try {
            ob_start();

            require $template;
        } finally {
            $output = ob_get_clean();
        }

        return $output;
    }

    /**
     * Renders a page
     *
     * @param string $template The template to render
     * @param array  $data     The template variables
     *
     * @return string The rendered page
     */
    public function renderPage(string $template, array $data = []): string
    {
        $content = $this->render($template, $data);

        $output = '';

        try {
            ob_start();

            require $this->basePage;
        } finally {
            $output = ob_get_clean();
        }

        return $output;
    }

    /**
     * Escapes the data used in templates
     *
     * @param string $data The data to escape
     *
     * @return string The escaped data
     */
    private function escape(string $data): string
    {
        return htmlspecialchars($data, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
    }

    /**
     * Magic getter
     *
     * http://3.bp.blogspot.com/-QWWMt9EIYGY/UYh2TDoTjcI/AAAAAAAACBc/OjfEmjyi2EU/s1600/magic+meme.gif
     *
     * @param mixed $key The key of the variable
     *
     * @return mixed The value of the variable
     *
     * @throws \CodeCollab\Template\UndefinedVariableException
     */
    public function __get($key)<commit_msg>Made properties and methods protected<commit_after><?php declare(strict_types=1);
/**
 * HTML page template renderer
 *
 * PHP version 7.0
 *
 * @category   CodeCollab
 * @package    Template
 * @author     <NAME> <<EMAIL>>
 * @copyright  Copyright (c) 2015 <NAME> <https://github.com/PeeHaa>
 * @license    See the LICENSE file
 * @version    1.0.0
 */
namespace CodeCollab\Template;

/**
 * HTML page template renderer
 *
 * @category   CodeCollab
 * @package    Template
 * @author     <NAME> <<EMAIL>>
 */
class Html implements Renderer
{
    /**
     * @var array List of template variables
     */
    protected $variables = [];

    /**
     * @var string The base (skeleton) page template
     */
    protected $basePage;

    /**
     * Creates instance
     *
     * @param string $basePage The base (skeleton) page template
     */
    public function __construct(string $basePage)
    {
        $this->basePage = $basePage;
    }

    /**
     * Renders a template
     *
     * @param string $template The template to render
     * @param array  $data     The template variables
     *
     * @return string The rendered template
     */
    public function render(string $template, array $data = []): string
    {
        if (!empty($data)) {
            $this->variables = $data;
        }

        $output = '';

        try {
            ob_start();

            require $template;
        } finally {
            $output = ob_get_clean();
        }

        return $output;
    }

    /**
     * Renders a page
     *
     * @param string $template The template to render
     * @param array  $data     The template variables
     *
     * @return string The rendered page
     */
    public function renderPage(string $template, array $data = []): string
    {
        $content = $this->render($template, $data);

        $output = '';

        try {
            ob_start();

            require $this->basePage;
        } finally {
            $output = ob_get_clean();
        }

        return $output;
    }

    /**
     * Escapes the data used in templates
     *
     * @param string $data The data to escape
     *
     * @return string The escaped data
     */
    protected function escape(string $data): string
    {
        return htmlspecialchars($data, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
    }

    /**
     * Magic getter
     *
     * http://3.bp.blogspot.com/-QWWMt9EIYGY/UYh2TDoTjcI/AAAAAAAACBc/OjfEmjyi2EU/s1600/magic+meme.gif
     *
     * @param mixed $key The key of the variable
     *
     * @return mixed The value of the variable
     *
     * @throws \CodeCollab\Template\UndefinedVariableException
     */
    public function __get($key)
{'fraction_non_alphanumeric': 0.11560044893378227, 'fraction_numerical': 0.00710811821922933, 'mean_word_length': 1.9395272127542607, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 27, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '4280773', 'n_tokens_mistral': 1632, 'n_tokens_neox': 1565, 'n_words': 429}