<commit_before><?php

namespace Pleets\Mvc;

class Application
{
	protected $module;
	protected $controller;
	protected $view;

	private $settings;

	public function __construct()
	{
		// Start sessions
		if (!isset($_SESSION))
			session_start();

		$_SESSION["APP"] = __CLASS__;

		// Get settings from application.config.php
		$this->settings = require "config/application.config.php";
		$settings = $this->getSettings();

		/*
		 *	APP CONSTANTS
		 */

		if (!array_key_exists('app', $settings))
			throw new \Exception("The key 'app' does not exists in the configuration file");
		if (!array_key_exists('base_path', $settings["app"]))
			throw new \Exception("The key 'base_path' does not exists in the configuration file");

		define('BASEPATH', $settings["app"]["base_path"]);

		/*
		 *	DEV MODE:
		 *	Set Development or production environment
		 */

		$devMode = (!array_key_exists('development_environment', $settings["app"]) || !$settings["app"]["development_environment"]) ? false : true;

		if (!ini_get('display_errors'))
		{
			if ($devMode)
			{
				ini_set('display_errors', 1);

				// See errors
				// error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);

				// PHP 5.4
				// error_reporting(E_ALL);

				// Best way to view all possible errors
				error_reporting(-1);
			}
			else {
				ini_set('display_errors', 0);
				error_reporting(-1);
			}
		}

		/*
		 *	GET URL PARAMETERS:
		 *	The route is constructed from the URL in the following order
		 *	www.example.com/module/controller/view
		 */

		$this->module = isset($_GET["module"]) ? $_GET["module"] : null;
		$this->controller = isset($_GET["controller"]) ? $_GET["controller"] : null;
		$this->view = isset($_GET["view"]) ? $_GET["view"] : null;

		$this->loadUserClasses($settings);

		$this->buildRoute($settings);
	}

	/* Getters */
	public function getModule() { return $this->module; }
	public function getController() { return $this->controller; }<commit_msg>Improve detecting errors<commit_after><?php

namespace Pleets\Mvc;

class Application
{
	protected $module;
	protected $controller;
	protected $view;

	private $settings;

	public function __construct()
	{
		// Start sessions
		if (!isset($_SESSION))
			session_start();

		$_SESSION["APP"] = __CLASS__;

		// Get settings from application.config.php
		$this->settings = require "config/application.config.php";
		$settings = $this->getSettings();

		/*
		 *	APP CONSTANTS
		 */

		if (!array_key_exists('app', $settings))
			throw new \Exception("The key 'app' does not exists in the configuration file");
		if (!array_key_exists('base_path', $settings["app"]))
			throw new \Exception("The key 'base_path' does not exists in the configuration file");

		define('BASEPATH', $settings["app"]["base_path"]);

		/*
		 *	DEV MODE:
		 *	Set Development or production environment
		 */

		$devMode = (!array_key_exists('development_environment', $settings["app"]) || !$settings["app"]["development_environment"]) ? false : true;

		if ($devMode)
		{
			ini_set('display_errors', 1);

			// See errors
			// error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);

			// PHP 5.4
			// error_reporting(E_ALL);

			// Best way to view all possible errors
			error_reporting(-1);
		}
		else {
			ini_set('display_errors', 0);
			error_reporting(-1);
		}

		/*
		 *	GET URL PARAMETERS:
		 *	The route is constructed from the URL in the following order
		 *	www.example.com/module/controller/view
		 */

		$this->module = isset($_GET["module"]) ? $_GET["module"] : null;
		$this->controller = isset($_GET["controller"]) ? $_GET["controller"] : null;
		$this->view = isset($_GET["view"]) ? $_GET["view"] : null;

		$this->loadUserClasses($settings);

		$this->buildRoute($settings);
	}

	/* Getters */
	public function getModule() { return $this->module; }
	public function getController() { return $this->controller; }
{'fraction_non_alphanumeric': 0.16067270375161707, 'fraction_numerical': 0.0031047865459249676, 'mean_word_length': 3.912325285895807, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1540705', 'n_tokens_mistral': 1381, 'n_tokens_neox': 1197, 'n_words': 292}