<commit_before><?php
namespace MOC\MarkIV\Core\Session\Handler\Source;

/**
 * Interface ISession
 *
 * @package MOC\MarkIV\Core\Session\Handler\Source
 */
interface ISessionInterface {

	/**
	 * @return void
	 */
	public function openSession();

	/**
	 * @return array
	 */
	public function getContent();

	/**
	 * @return void
	 */
	public function closeSession();

	/**
	 * @return void
	 */
	public function destroySession();
}

/**
 * Class Session
 *
 * @package MOC\MarkIV\Core\Session\Handler\Source
 */
class Session implements ISessionInterface {

	/** @var string $Identifier */
	private static $Identifier = __CLASS__;

	/**
	 * @param null|string $Identifier
	 * @param bool        $AutoOpen
	 */
	function __construct( $Identifier = null, $AutoOpen = true ) {

		if( null === $Identifier ) {
			self::$Identifier = __CLASS__;
		} else {
			self::$Identifier = $Identifier;
		}

		if( true === $AutoOpen ) {
			$this->openSession();
		}
	}

	/**
	 * @return void
	 */
	public function openSession() {

		if( !strlen( session_id() ) > 0 ) {
			session_start();
		}
		if( !isset( $_SESSION[self::$Identifier] ) ) {
			$_SESSION[self::$Identifier] = array();
		}
	}

	/**
	 * @return void
	 */
	public function closeSession() {

		session_write_close();
	}

	/**
	 * @return void
	 */
	public function destroySession() {
		if( $this->isSessionAvailable() ) {
			session_destroy();
		}
	}

	/**
	 * @return array
	 */
	public function &getContent() {

		$Reference = & $_SESSION[self::$Identifier];

		return $Reference;
	}

	/**
	 * @return bool
	 */
	private function isSessionAvailable() {

		if( php_sapi_name() !== 'cli' ) {
			if( version_compare( phpversion(), '5.4.0', '>=' ) ) {
				return session_status() === PHP_SESSION_ACTIVE ? true : false;
			} else {
				return session_id() === '' ? false : true;
			}
		}

		return false;
	}
}<commit_msg>Core: Improved Session<commit_after><?php
namespace MOC\MarkIV\Core\Session\Handler\Source;

/**
 * Interface ISession
 *
 * @package MOC\MarkIV\Core\Session\Handler\Source
 */
interface ISessionInterface {

	/**
	 * @return void
	 */
	public function openSession();

	/**
	 * @return array
	 */
	public function getContent();

	/**
	 * @return void
	 */
	public function closeSession();

	/**
	 * @return void
	 */
	public function destroySession();
}

/**
 * Class Session
 *
 * @package MOC\MarkIV\Core\Session\Handler\Source
 */
class Session implements ISessionInterface {

	/** @var string $Identifier */
	private static $Identifier = __CLASS__;

	/**
	 * @param null|string $Identifier
	 * @param bool        $AutoOpen
	 */
	function __construct( $Identifier = null, $AutoOpen = true ) {

		if( null === $Identifier ) {
			self::$Identifier = __CLASS__;
		} else {
			self::$Identifier = $Identifier;
		}

		if( true === $AutoOpen ) {
			$this->openSession();
		}
	}

	/**
	 * @return void
	 */
	public function openSession() {

		if( !$this->isSessionAvailable() ) {
			session_start();
		}
		if( !isset( $_SESSION[self::$Identifier] ) ) {
			$_SESSION[self::$Identifier] = array();
		}
	}

	/**
	 * @return void
	 */
	public function closeSession() {

		session_write_close();
	}

	/**
	 * @return void
	 */
	public function destroySession() {

		if( $this->isSessionAvailable() ) {
			session_destroy();
		}
	}

	/**
	 * @return bool
	 */
	private function isSessionAvailable() {

		if( version_compare( phpversion(), '5.4.0', '>=' ) ) {
			return session_status() === PHP_SESSION_ACTIVE ? true : false;
		} else {
			return session_id() === '' ? false : true;
		}
	}

	/**
	 * @return array
	 */
	public function &getContent() {

		$Reference = & $_SESSION[self::$Identifier];

		return $Reference;
	}
}
{'fraction_non_alphanumeric': 0.16988312041315576, 'fraction_numerical': 0.0019026909486273443, 'mean_word_length': 3.116331096196868, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '7645144', 'n_tokens_mistral': 1324, 'n_tokens_neox': 1177, 'n_words': 255}