<commit_before><?php 
/**
 * WSystem.php
 */

defined('IN_WITY') or die('Access denied');

/**
 * WSystem keeps the session, template and database instances as singletons
 * 
 * <p>If you need the WSession instance, just call :
 * <code>WSystem::getSession();</code>
 * It's the same thing with WTemplate andWDatabase.
 * </p>
 *
 * @package System\WCore
 * @author <NAME> <<EMAIL>>
 * @version 0.3-28-09-2012
 */
class WSystem {
	
	/**
	 * @var WSession Session object
	 */
	private static $sessionInstance;
	
	/**
	 * @var WTemplate WTemplate object
	 */
	private static $templateInstance;
	
	/**
	 * @var WDatabase WDatabase object
	 */
	private static $dbInstance;
	
	/**
	 * Returns current session or creates it if it doesn't exist yet
	 * @return WSession returns current session
	 */
	public static function getSession() {
		if (!is_object(self::$sessionInstance)) {
			include_once SYS_DIR.'WCore/WSession.php';
			self::$sessionInstance = new WSession();
		}
		
		return self::$sessionInstance;
	}
	
	/**
	 * Returns current template or creates it if it doesn't exist yet
	 * @return WSession returns current template
	 */
	public static function getTemplate() {
		if (!is_object(self::$templateInstance)) {
			include_once SYS_DIR.'WTemplate/WTemplate.php';
			try {
				self::$templateInstance = new WTemplate(WITY_PATH, CACHE_DIR.'templates'.DS);
			} catch (Exception $e) {
				WNote::error('system_template_instantiation', $e->getMessage(), 'die');
			}
		}
		
		return self::$templateInstance;
	}
	
	/**
	 * Returns current database manager or creates it if it doesn't exist yet
	 * @return WSession returns current database manager
	 */
	public static function getDB() {
		if (!is_object(self::$dbInstance)) {
			// Chargement des infos db
			WConfig::load('database', SYS_DIR.'config'.DS.'database.php', 'php');
			
			$dsn = 'mysql:dbname='.WConfig::get('database.dbname').';host='.WConfig::get('database.server');
			$user = WConfig::get('database.user');<commit_msg>Changed include_once to require_once<commit_after><?php 
/**
 * WSystem.php
 */

defined('IN_WITY') or die('Access denied');

/**
 * WSystem keeps the session, template and database instances as singletons
 * 
 * <p>If you need the WSession instance, just call :
 * <code>WSystem::getSession();</code>
 * It's the same thing with WTemplate andWDatabase.
 * </p>
 *
 * @package System\WCore
 * @author <NAME> <<EMAIL>>
 * @version 0.3-28-09-2012
 */
class WSystem {
	
	/**
	 * @var WSession Session object
	 */
	private static $sessionInstance;
	
	/**
	 * @var WTemplate WTemplate object
	 */
	private static $templateInstance;
	
	/**
	 * @var WDatabase WDatabase object
	 */
	private static $dbInstance;
	
	/**
	 * Returns current session or creates it if it doesn't exist yet
	 * @return WSession returns current session
	 */
	public static function getSession() {
		if (!is_object(self::$sessionInstance)) {
			require_once SYS_DIR.'WCore/WSession.php';
			self::$sessionInstance = new WSession();
		}
		
		return self::$sessionInstance;
	}
	
	/**
	 * Returns current template or creates it if it doesn't exist yet
	 * @return WSession returns current template
	 */
	public static function getTemplate() {
		if (!is_object(self::$templateInstance)) {
			require_once SYS_DIR.'WTemplate/WTemplate.php';
			try {
				self::$templateInstance = new WTemplate(WITY_PATH, CACHE_DIR.'templates'.DS);
			} catch (Exception $e) {
				WNote::error('system_template_instantiation', $e->getMessage(), 'die');
			}
		}
		
		return self::$templateInstance;
	}
	
	/**
	 * Returns current database manager or creates it if it doesn't exist yet
	 * @return WSession returns current database manager
	 */
	public static function getDB() {
		if (!is_object(self::$dbInstance)) {
			// Chargement des infos db
			WConfig::load('database', SYS_DIR.'config'.DS.'database.php', 'php');
			
			$dsn = 'mysql:dbname='.WConfig::get('database.dbname').';host='.WConfig::get('database.server');
			$user = WConfig::get('database.user');
{'fraction_non_alphanumeric': 0.14310733049787341, 'fraction_numerical': 0.005003752814610958, 'mean_word_length': 3.9602977667493797, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '2066741', 'n_tokens_mistral': 1352, 'n_tokens_neox': 1203, 'n_words': 330}