<commit_before><?php

namespace Slim\Views;

use League\Plates\Engine;
use Slim\View;

class Plates extends View
{
    /**
     * @var Engine $_engine
     */
    static $_engine;

    private $_construct = array();

    public function __construct($init = null)
    {
        parent::__construct();
        if ($init && is_callable($init)) {
            $this->_construct = array($init);
        } elseif (is_array($init)) {
            $this->_construct = $init;
        }
    }

    public function render($templateFile, $data = null)
    {
        if (!isset(static::$_engine)) {
            $engine = new Engine($this->getTemplatesDirectory());

            $funcs = $this->_construct;
            foreach ($funcs as $func) {
                if (is_callable($func)) {
                    call_user_func($func, $engine);
                }
            }
            static::$_engine = $engine;
        }

        $template = static::$_engine->makeTemplate();
        $template->data($this->all());
        return $template->render($templateFile, $data);
    }
}<commit_msg>PHPDoc<commit_after><?php

namespace Slim\Views;

use Closure;
use League\Plates\Engine;
use Slim\View;

/**
 * Class Plates
 * @package Slim\Views
 */
class Plates extends View
{
    /**
     * @var Engine $_engine
     */
    static $_engine;

    private $_construct = array();

    /**
     * {@inheritdoc}
     *
     * @param null|Closure|array $init
     */
    public function __construct($init = null)
    {
        parent::__construct();
        if ($init && is_callable($init)) {
            $this->_construct = array($init);
        } elseif (is_array($init)) {
            $this->_construct = $init;
        }
    }

    /**
     * {@inheritdoc}
     *
     * @param string $templateFile
     * @param null $data
     * @return string
     */
    public function render($templateFile, $data = null)
    {
        if (!isset(static::$_engine)) {
            $engine = new Engine($this->getTemplatesDirectory());

            $funcs = $this->_construct;
            foreach ($funcs as $func) {
                if (is_callable($func)) {
                    call_user_func($func, $engine);
                }
            }
            static::$_engine = $engine;
        }

        $template = static::$_engine->makeTemplate();
        $template->data($this->all());
        return $template->render($templateFile, $data);
    }
}
{'fraction_non_alphanumeric': 0.1503728251864126, 'fraction_numerical': 0.0, 'mean_word_length': 1.89568345323741, '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': '1031438', 'n_tokens_mistral': 707, 'n_tokens_neox': 691, 'n_words': 141}