<commit_before><?php

/*
 * To use Twig rendering, ensure your composer.json file contains
 * the following:
 *
 * "require": {
 *      "twig/twig": "~1.0"
 * }
 */

namespace Frame\Response;

class Twig extends Foundation implements ResponseInterface
{

    protected $contentType = 'text/html';
    protected $defaultExtension = '.twig';

    public function __construct()
    {

        // Check that Twig is loaded
        if (!class_exists("Twig_Environment")) {
            throw new \Exception("Twig is not installed, Response class cannot be used.");
        }

    }

    public function render($params = null)
    {

        // Instantiate the Twig library only once, keep it global
        if (!isset($this->project->config->twig)) {

            // Make sure we can determine which template to render
            if (!$this->viewBaseDir) {
                throw new \Exception("Twig responder class only works within a controller.");
            }

            // Check for existence of cache directory before instantiating Twig
            $cacheDir = $this->viewBaseDir . '/cache';
            if ((!file_exists($cacheDir)) || (!is_writable($cacheDir))) {
                throw new \Exception("Twig responder class requires the directory " . $cacheDir . ', and it must be writable');
            }

            // Initialize Twig
            $this->project->config->twig = new \Twig_Environment(new \Twig_Loader_Filesystem($this->viewBaseDir), array(
                'cache' => $this->viewBaseDir . '/cache',
            ));

        }

        $params = ($params ?: $this->viewParams);<commit_msg>Slight leniency<commit_after><?php

/*
 * To use Twig rendering, ensure your composer.json file contains
 * the following:
 *
 * "require": {
 *      "twig/twig": "~1.0"
 * }
 */

namespace Frame\Response;

class Twig extends Foundation implements ResponseInterface
{

    protected $contentType = 'text/html';
    protected $defaultExtension = '.twig';

    public function __construct()
    {

        // Check that Twig is loaded
        if (!class_exists("Twig_Environment")) {
            throw new \Exception("Twig is not installed, Response class cannot be used.");
        }

    }

    public function render($params = null)
    {

        // Instantiate the Twig library only once, keep it global
        if (!isset($this->project->config->twig)) {

            // Make sure we can determine which template to render
            if (!$this->viewBaseDir) {
                throw new \Exception("Twig responder class cannot determine view file/path automatically. Please set using \$responder->setViewBaseDir() and \$responder->setViewFilename()");
            }

            // Check for existence of cache directory before instantiating Twig
            $cacheDir = $this->viewBaseDir . '/cache';
            if ((!file_exists($cacheDir)) || (!is_writable($cacheDir))) {
                throw new \Exception("Twig responder class requires the directory " . $cacheDir . ', and it must be writable');
            }

            // Initialize Twig
            $this->project->config->twig = new \Twig_Environment(new \Twig_Loader_Filesystem($this->viewBaseDir), array(
                'cache' => $this->viewBaseDir . '/cache',
            ));

        }

        $params = ($params ?: $this->viewParams);
{'fraction_non_alphanumeric': 0.12187782124586218, 'fraction_numerical': 0.0012037315678603672, 'mean_word_length': 2.2684365781710913, 'pattern_counts': {'":': 4, '<': 5, '<?xml version=': 0, '>': 29, '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': '785759', 'n_tokens_mistral': 891, 'n_tokens_neox': 857, 'n_words': 265}