<commit_before><?php

namespace nadir\core;

use extensions\core\Process;

/**
 * This's an abstract application class. It determines the central entry point for
 * the all requests, creates the configured application. It implements Front 
 * Controller pattern, it's Singleton-instance.
 * @author coon
 */
abstract class AbstractApp extends AbstractAutoAccessors implements FrontControllerInterface,
    RunnableInterface
{
    /** @var string This's path to the config file root. */
    public $configFile = null;

    /** @var string The path to the root of application. */
    public $appRoot = null;

    /** @var self This's singleton object of the current class. */
    protected static $instance = null;

    /**
     * @ignore.
     */
    protected function __construct()
    {
        // Nothing here...
    }

    /**
     * It returns the context called singleton-instance. It implements late static
     * binding.
     * @return self.
     */
    public static function getInstance()
    {
        if (is_null(static::$instance)) {
            static::$instance = new static();
        }
        return static::$instance;
    }

    /**
     * It sets the path to the main application config file referenced to its root.
     * @param string $sFilePath.
     * @return self.
     */
    public function setConfigFile($sFilePath)
    {
        $this->configFile = $sFilePath;
        return static::$instance;
    }

    /**
     * It sets the root of application.
     * @param string $sAppRoot The path to the application root.
     * @return self.
     */
    public function setAppRoot($sAppRoot)
    {
        $this->appRoot = $sAppRoot;
        return static::$instance;
    }

    /**
     * {@inheritdoc}
     */
    public function run()
    {
        $this->init();
    }

    /**
     * {@inheritdoc}
     */
    public function init()
    {
        $this->initHelper();
        $this->initUserProcess();
        $this->handleRequest();
        $this->stopUserProcess();
    }

    /**
     * {@inheritdoc}
     */
    abstract public function handleRequest();

    /**
     * It inits the application helper.
     * @return void.
     */
    private function initHelper()
    {
        if (!$this->isConfigFileSet()) {
            throw new Exception("The main config file wasn't defined.");
        }
        if (!$this->isAppRootSet()) {
            throw new Exception("The application root wasn't defined.");
        }
        AppHelper::getInstance()
            ->setAppRoot($this->getAppRoot())
            ->setConfigFile($this->getConfigFile())
            ->run();
    }

    /**
     * The method runs custom processes.
     * @return void.
     */
    private function initUserProcess()
    {
        Process::getInstance()->run();
    }

    /**
     * The method kills user's processes.
     * @return void.
     */
    private function stopUserProcess()
    {
        Process::getInstance()->stop();
    }
}<commit_msg>The default values of some class variables were updated with empty string. Task #3 - Add composer autoloading support with PSR-4 compatibility.<commit_after><?php

namespace nadir\core;

use extensions\core\Process;

/**
 * This's an abstract application class. It determines the central entry point for
 * the all requests, creates the configured application. It implements Front 
 * Controller pattern, it's Singleton-instance.
 * @author coon
 */
abstract class AbstractApp extends AbstractAutoAccessors implements FrontControllerInterface,
    RunnableInterface
{
    /** @var string This's path to the config file root. */
    public $configFile = '';

    /** @var string The path to the root of application. */
    public $appRoot = '';

    /** @var self This's singleton object of the current class. */
    protected static $instance = null;

    /**
     * @ignore.
     */
    protected function __construct()
    {
        // Nothing here...
    }

    /**
     * It returns the context called singleton-instance. It implements late static
     * binding.
     * @return self.
     */
    public static function getInstance()
    {
        if (is_null(static::$instance)) {
            static::$instance = new static();
        }
        return static::$instance;
    }

    /**
     * It sets the path to the main application config file referenced to its root.
     * @param string $sFilePath.
     * @return self.
     */
    public function setConfigFile($sFilePath)
    {
        $this->configFile = $sFilePath;
        return static::$instance;
    }

    /**
     * It sets the root of application.
     * @param string $sAppRoot The path to the application root.
     * @return self.
     */
    public function setAppRoot($sAppRoot)
    {
        $this->appRoot = $sAppRoot;
        return static::$instance;
    }

    /**
     * {@inheritdoc}
     */
    public function run()
    {
        $this->init();
    }

    /**
     * {@inheritdoc}
     */
    public function init()
    {
        $this->initHelper();
        $this->initUserProcess();
        $this->handleRequest();
        $this->stopUserProcess();
    }

    /**
     * {@inheritdoc}
     */
    abstract public function handleRequest();

    /**
     * It inits the application helper.
     * @return void.
     */
    private function initHelper()
    {
        if (!$this->isConfigFileSet()) {
            throw new Exception("The main config file wasn't defined.");
        }
        if (!$this->isAppRootSet()) {
            throw new Exception("The application root wasn't defined.");
        }
        AppHelper::getInstance()
            ->setAppRoot($this->getAppRoot())
            ->setConfigFile($this->getConfigFile())
            ->run();
    }

    /**
     * The method runs custom processes.
     * @return void.
     */
    private function initUserProcess()
    {
        Process::getInstance()->run();
    }

    /**
     * The method kills user's processes.
     * @return void.
     */
    private function stopUserProcess()
    {
        Process::getInstance()->stop();
    }
}
{'fraction_non_alphanumeric': 0.12218915343915344, 'fraction_numerical': 0.00033068783068783067, 'mean_word_length': 2.076805696846389, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 35, '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': '1326294', 'n_tokens_mistral': 1626, 'n_tokens_neox': 1592, 'n_words': 480}