<commit_before><?php

namespace Nip;

use Nip\Container\Container;
use Nip\DebugBar\StandardDebugBar;
use Nip\Logger\Manager as LoggerManager;
use Nip\Profiler\Adapters\DebugBar as ProfilerDebugBar;
use Nip\Staging\Stage;

class Application
{
    /**
     * @var AutoLoader
     */
    protected $_autoloader = null;

    protected $_frontController = null;

    protected $_container = null;

    protected $_request = null;
    /**
     * @var null|LoggerManager
     */
    protected $_logger = null;

    protected $_sessionManager = null;

    protected $_debugBar = null;

    /**
     * @var Staging
     */
    protected $_staging;

    /**
     * @var Stage
     */
    protected $_stage;

    public function run()
    {
        $this->loadFiles();
        $this->prepare();
        $this->setup();
        $this->dispatch();
    }

    public function loadFiles()
    {
    }

    public function prepare()
    {
        $this->includeVendorAutoload();
        $this->setupContainer();
        $this->setupRequest();
        $this->setupStaging();
        $this->setupAutoloader();
        $this->setupErrorHandling();
        $this->setupURLConstants();
    }

    public function setup()
    {
        $this->setupConfig();
        $this->setupDatabase();
        $this->setupSession();
        $this->setupTranslation();
        $this->setupLocale();
        $this->setupRouting();
    }

    public function setupConfig()
    {

    }

    public function setupStaging()
    {
        $this->getFrontController()->setStaging($this->getStaging());
        $this->getFrontController()->setStage($this->getStage());
    }

    /**
     * @return Staging
     */
    public function getStaging()
    {
        if ($this->_staging == null) {
            $this->initStaging();
        }
        return $this->_staging;
    }

    public function initStaging()
    {
        $this->_staging = $this->newStaging();
    }

    public function newStaging()
    {
        return Staging::instance();
    }

    public function getStage()
    {
        if ($this->_staging == null) {
            $this->initStage();
        }
        return $this->_stage;
    }

    public function initStage()
    {
        $this->_stage = $this->getStaging()->getStage();
    }

    public function getAutoloader()
    {
        if ($this->_autoloader == null) {
            $this->initAutoloader();
        }
        return $this->_autoloader;
    }

    public function initAutoloader()
    {
        $this->_autoloader = AutoLoader::instance();
    }

    public function setupAutoloader()
    {
        $this->setupAutoloaderCache();
        $this->setupAutoloaderPaths();

        if ($this->getStage()->inTesting()) {<commit_msg>add getStaging to Application<commit_after><?php

namespace Nip;

use Nip\Container\Container;
use Nip\DebugBar\StandardDebugBar;
use Nip\Logger\Manager as LoggerManager;
use Nip\Profiler\Adapters\DebugBar as ProfilerDebugBar;
use Nip\Staging\Stage;

class Application
{
    /**
     * @var AutoLoader
     */
    protected $_autoloader = null;

    protected $_frontController = null;

    protected $_container = null;

    protected $_request = null;
    /**
     * @var null|LoggerManager
     */
    protected $_logger = null;

    protected $_sessionManager = null;

    protected $_debugBar = null;

    /**
     * @var Staging
     */
    protected $_staging = null;

    /**
     * @var Stage
     */
    protected $_stage = null;

    public function run()
    {
        $this->loadFiles();
        $this->prepare();
        $this->setup();
        $this->dispatch();
    }

    public function loadFiles()
    {
    }

    public function prepare()
    {
        $this->includeVendorAutoload();
        $this->setupContainer();
        $this->setupRequest();
        $this->setupStaging();
        $this->setupAutoloader();
        $this->setupErrorHandling();
        $this->setupURLConstants();
    }

    public function setup()
    {
        $this->setupConfig();
        $this->setupDatabase();
        $this->setupSession();
        $this->setupTranslation();
        $this->setupLocale();
        $this->setupRouting();
    }

    public function setupConfig()
    {

    }

    public function setupStaging()
    {
        $this->getFrontController()->setStaging($this->getStaging());
        $this->getFrontController()->setStage($this->getStage());
    }

    /**
     * @return Staging
     */
    public function getStaging()
    {
        if ($this->_staging == null) {
            $this->initStaging();
        }
        return $this->_staging;
    }

    public function initStaging()
    {
        $this->_staging = $this->newStaging();
    }

    public function newStaging()
    {
        return Staging::instance();
    }

    public function getStage()
    {
        if ($this->_stage == null) {
            $this->initStage();
        }
        return $this->_stage;
    }

    public function initStage()
    {
        $this->_stage = $this->getStaging()->getStage();
    }

    public function getAutoloader()
    {
        if ($this->_autoloader == null) {
            $this->initAutoloader();
        }
        return $this->_autoloader;
    }

    public function initAutoloader()
    {
        $this->_autoloader = AutoLoader::instance();
    }

    public function setupAutoloader()
    {
        $this->setupAutoloaderCache();
        $this->setupAutoloaderPaths();

        if ($this->getStage()->inTesting()) {
{'fraction_non_alphanumeric': 0.14280496712929144, 'fraction_numerical': 0.0, 'mean_word_length': 2.090857787810384, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 87, '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': '2535007', 'n_tokens_mistral': 1635, 'n_tokens_neox': 1594, 'n_words': 295}