<commit_before><?php

namespace kiwi\Http;

use kiwi\System\Filesystem;
use kiwi\System\Templating\Engine;

class View
{
    /**
     * Render a view.
     *
     * @param string $view
     * @param array  $extracts
     *
     * @return View
     */
    public static function render($view, array $extracts = [])
    {
        self::finish($view . '.view.php', $extracts);
    }

    /**
     * Render an admin view.
     *
     * @param string $view
     * @param array  $extracts
     */
    public static function renderAdminView($view, array $extracts = [])
    {
        $view = 'framework' . DIRECTORY_SEPARATOR . 'Admin' . DIRECTORY_SEPARATOR . 'Views' . DIRECTORY_SEPARATOR . $view;

        extract($extracts);

        return require $view . '.view.php';
    }

    /**
     * Extract variables, apply error bag and compile the view.
     *
     * @param string $view
     * @param array  $extracts
     *
     * @return void
     */
    public static function finish($view, array $extracts = [])
    {
        $extracts['errors'] = resolve('bag');

        // if (Filesystem::find("cache/{$view}")) {
        //     extract($extracts);
        //
        //     return require "cache/{$view}";
        // }

        $engine = new Engine("app/Views/{$view}", $extracts);

        $engine->compile();
    }
}<commit_msg>refactor viw<commit_after><?php

namespace kiwi\Http;

use kiwi\System\Filesystem;
use kiwi\System\Templating\Engine;

class View
{
    /**
     * Render a view.
     *
     * @param string $view
     * @param array  $extracts
     *
     * @return View
     */
    public static function render($view, array $extracts = [])
    {
        self::finish($view . '.view.php', $extracts);
    }

    /**
     * Render an admin view.
     *
     * @param string $view
     * @param array  $extracts
     */
    public static function renderAdminView($view, array $extracts = [])
    {
        $view = 'framework' . DIRECTORY_SEPARATOR . 'Admin' . DIRECTORY_SEPARATOR . 'Views' . DIRECTORY_SEPARATOR . $view;

        extract($extracts);

        return require $view . '.view.php';
    }

    /**
     * Extract variables, apply error bag and compile the view.
     *
     * @param string $view
     * @param array  $extracts
     *
     * @return void
     */
    public static function finish($view, array $extracts = [])
    {
        $extracts['errors'] = resolve('bag');

        if (!Filesystem::find("cache/{$view}")) {
            $engine = new Engine("app/Views/{$view}");

            $engine->compile();
        }

        extract($extracts);

        return require "cache/{$view}";
    }
}
{'fraction_non_alphanumeric': 0.14883897982489533, 'fraction_numerical': 0.0, 'mean_word_length': 1.9965792474344355, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6779000', 'n_tokens_mistral': 829, 'n_tokens_neox': 810, 'n_words': 188}