<commit_before><?php

// ==================================================================
// Base controller class
// ==================================================================

class TipyController {

    public $config;            // Config
    public $in;                // Input wrapper
    public $out;               // Output data holder
    public $env;               // Environment wrapper
    public $view;              // Template Renderer
    public $db;                // DB Handler
    public $session;           // Session
    public $cookie;            // Cookies placeholder
    protected $flash;

    // Application Constructor
    public function __construct() {
        $app = TipyApp::getInstance();
        $this->config     = $app->config;
        $this->request    = $app->request;
        $this->in         = $app->in;
        $this->out        = $app->out;
        $this->env        = $app->env;
        $this->cookie     = $app->cookie;
        $this->view       = $app->view;
        $this->db         = $app->db;
        $this->session    = $app->session;
        $this->flash      = new TipyFlash($this->session);
    }

    public function in($name, $defaultValue = null) {
        return $this->in->get($name, $defaultValue);
    }

    public function out($name, $value) {
        return $this->out->set($name, $value);
    }

    // --------------------------------------------------------------
    // Debug fuction
    // --------------------------------------------------------------
    public function dump() {
        print_r($this);
    }

    // --------------------------------------------------------------
    // rturn View as string
    // --------------------------------------------------------------
    public function renderTemplate($templateName) {
        $this->executeAfter();
        $this->view->bind($this->out->getAll());
        $output = $this->view->processTemplate($templateName);
        return $output;
    }

    // --------------------------------------------------------------
    // render View (show output)
    // --------------------------------------------------------------
    public function renderView($templateName) {
        echo $this->renderTemplate($templateName);
    }

    // --------------------------------------------------------------
    // Calls executeBefore() callback and execute action
    // --------------------------------------------------------------
    public function execute($action) {
        $this->executeBefore();
        $this->$action();
    }

    // --------------------------------------------------------------
    // exit function wrapper for tests compability
    // --------------------------------------------------------------
    private function safeExit($message) {
        if (defined('TEST_MODE') and TEST_MODE) {
            throw new TipyException($msg);
        } else {
            exit;
        }
    }

    // --------------------------------------------------------------
    // Redirect
    // --------------------------------------------------------------
    public function redirect($path) {
        while (@ob_end_clean()) {
        }
        header('HTTP/1.0 302 Moved Temporarily');
        header('Location: '.$path);
        $this->safeExit('Redirected to '.$path);
    }

    // --------------------------------------------------------------
    // 404
    // --------------------------------------------------------------
    public function pageNotFound() {
        while (@ob_end_clean()) {
        }
        header('HTTP/1.0 404 Not Found');
        $this->safeExit('Status: 404 Not Found');
    }

    // --------------------------------------------------------------
    // Default actions that are to be executed before ::execute()
    // --------------------------------------------------------------
    public function executeBefore() {
        // override this
    }

    // --------------------------------------------------------------
    // Default actions that are to be executed before ::execute()
    // --------------------------------------------------------------
    public function executeAfter() {
        // override this
    }
}
<commit_msg>Removed extra comments<commit_after><?php

// ==================================================================
// Base controller class
// ==================================================================

class TipyController {

    public $config;
    public $in;
    public $out;
    public $env;
    public $view;
    public $db;
    public $session;
    public $cookie;
    protected $flash;

    // Application Constructor
    public function __construct() {
        $app = TipyApp::getInstance();
        $this->config   = $app->config;
        $this->request  = $app->request;
        $this->in       = $app->in;
        $this->out      = $app->out;
        $this->env      = $app->env;
        $this->cookie   = $app->cookie;
        $this->view     = $app->view;
        $this->db       = $app->db;
        $this->session  = $app->session;
        $this->flash     = new TipyFlash($this->session);
    }

    public function in($name, $defaultValue = null) {
        return $this->in->get($name, $defaultValue);
    }

    public function out($name, $value) {
        return $this->out->set($name, $value);
    }

    // --------------------------------------------------------------
    // Debug fuction
    // --------------------------------------------------------------
    public function dump() {
        print_r($this);
    }

    // --------------------------------------------------------------
    // rturn View as string
    // --------------------------------------------------------------
    public function renderTemplate($templateName) {
        $this->executeAfter();
        $this->view->bind($this->out->getAll());
        $output = $this->view->processTemplate($templateName);
        return $output;
    }

    // --------------------------------------------------------------
    // render View (show output)
    // --------------------------------------------------------------
    public function renderView($templateName) {
        echo $this->renderTemplate($templateName);
    }

    // --------------------------------------------------------------
    // Calls executeBefore() callback and execute action
    // --------------------------------------------------------------
    public function execute($action) {
        $this->executeBefore();
        $this->$action();
    }

    // --------------------------------------------------------------
    // exit function wrapper for tests compability
    // --------------------------------------------------------------
    private function safeExit($message) {
        if (defined('TEST_MODE') and TEST_MODE) {
            throw new TipyException($msg);
        } else {
            exit;
        }
    }

    // --------------------------------------------------------------
    // Redirect
    // --------------------------------------------------------------
    public function redirect($path) {
        while (@ob_end_clean()) {
        }
        header('HTTP/1.0 302 Moved Temporarily');
        header('Location: '.$path);
        $this->safeExit('Redirected to '.$path);
    }

    // --------------------------------------------------------------
    // 404
    // --------------------------------------------------------------
    public function pageNotFound() {
        while (@ob_end_clean()) {
        }
        header('HTTP/1.0 404 Not Found');
        $this->safeExit('Status: 404 Not Found');
    }

    // --------------------------------------------------------------
    // Default actions that are to be executed before ::execute()
    // --------------------------------------------------------------
    public function executeBefore() {
        // override this
    }

    // --------------------------------------------------------------
    // Default actions that are to be executed before ::execute()
    // --------------------------------------------------------------
    public function executeAfter() {
        // override this
    }
}

{'fraction_non_alphanumeric': 0.4053789731051345, 'fraction_numerical': 0.003911980440097799, 'mean_word_length': 0.8712259835315646, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 75, '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': '3673787', 'n_tokens_mistral': 1710, 'n_tokens_neox': 1639, 'n_words': 379}