<commit_before><?php namespace Laravel;

if (Config::get('application.key') === '')
{
	throw new \Exception("An application key is required to use sessions.");
}

class Session {

	/**
	 * The session singleton instance for the request.
	 *
	 * @var Payload
	 */
	public static $instance;

	/**
	 * The string name of the CSRF token stored in the session.
	 *
	 * @var string
	 */
	const csrf_token = 'csrf_token';

	/**
	 * Create the session payload instance and load the session for the request.
	 *
	 * @param  string  $driver
	 * @return void
	 */
	public static function start($driver)
	{
		static::$instance = new Session\Payload(static::factory($driver));
	}

	/**
	 * Create a new session driver instance.
	 *
	 * @param  string  $driver
	 * @return Driver
	 */
	protected static function factory($driver)
	{
		switch ($driver)
		{
			case 'apc':
				return new Session\Drivers\APC(Cache::driver('apc'));

			case 'cookie':
				return new Session\Drivers\Cookie;

			case 'database':
				return new Session\Drivers\Database(Database::connection());

			case 'file':
				return new Session\Drivers\File(SESSION_PATH);

			case 'memcached':
				return new Session\Drivers\Memcached(Cache::driver('memcached'));

			case 'redis':
				return new Session\Drivers\Redis(Cache::driver('redis'));

			default:
				throw new \Exception("Session driver [$driver] is not supported.");
		}
	}

	/**
	 * Retrieve the active session payload instance for the request.
	 *
	 * <code>
	 *		// Retrieve the session instance and get an item
	 *		Session::instance()->get('name');
	 *
	 *		// Retrieve the session instance and place an item in the session
	 *		Session::instance()->put('name', 'Taylor');
	 * </code>
	 *
	 * @return Payload
	 */
	public static function instance()
	{
		if (static::started()) return static::$instance;

		throw new \Exception("A driver must be set before using the session.");
	}

	/**
	 * Determine if session handling has been started for the request.
	 *
	 * @return bool
	 */
	public static function started()
	{
		return ! is_null(static::$instance);
	}

	/**
	 * Magic Method for calling the methods on the session singleton instance.
	 *
	 * <code>
	 *		// Retrieve a value from the session
	 *		$value = Session::get('name');
	 *
	 *		// Write a value to the session storage
	 *		$value = Session::put('name', 'Taylor');
	 *
	 *		// Equivalent statement using the "instance" method
	 *		$value = Session::instance()->put('name', 'Taylor');
	 * </code>
	 */
	public static function __callStatic($method, $parameters)
	{
		return call_user_func_array(array(static::$instance, $method), $parameters);
	}

}<commit_msg>Session throws an Exception when it's not started<commit_after><?php namespace Laravel;

if (Config::get('application.key') === '')
{
	throw new \Exception("An application key is required to use sessions.");
}

class Session {

	/**
	 * The session singleton instance for the request.
	 *
	 * @var Payload
	 */
	public static $instance;

	/**
	 * The string name of the CSRF token stored in the session.
	 *
	 * @var string
	 */
	const csrf_token = 'csrf_token';

	/**
	 * Create the session payload instance and load the session for the request.
	 *
	 * @param  string  $driver
	 * @return void
	 */
	public static function start($driver)
	{
		static::$instance = new Session\Payload(static::factory($driver));
	}

	/**
	 * Create a new session driver instance.
	 *
	 * @param  string  $driver
	 * @return Driver
	 */
	protected static function factory($driver)
	{
		switch ($driver)
		{
			case 'apc':
				return new Session\Drivers\APC(Cache::driver('apc'));

			case 'cookie':
				return new Session\Drivers\Cookie;

			case 'database':
				return new Session\Drivers\Database(Database::connection());

			case 'file':
				return new Session\Drivers\File(SESSION_PATH);

			case 'memcached':
				return new Session\Drivers\Memcached(Cache::driver('memcached'));

			case 'redis':
				return new Session\Drivers\Redis(Cache::driver('redis'));

			default:
				throw new \Exception("Session driver [$driver] is not supported.");
		}
	}

	/**
	 * Retrieve the active session payload instance for the request.
	 *
	 * <code>
	 *		// Retrieve the session instance and get an item
	 *		Session::instance()->get('name');
	 *
	 *		// Retrieve the session instance and place an item in the session
	 *		Session::instance()->put('name', 'Taylor');
	 * </code>
	 *
	 * @return Payload
	 */
	public static function instance()
	{
		if (static::started()) return static::$instance;

		throw new \Exception("A driver must be set before using the session.");
	}

	/**
	 * Determine if session handling has been started for the request.
	 *
	 * @return bool
	 */
	public static function started()
	{
		return ! is_null(static::$instance);
	}

	/**
	 * Magic Method for calling the methods on the session singleton instance.
	 *
	 * <code>
	 *		// Retrieve a value from the session
	 *		$value = Session::get('name');
	 *
	 *		// Write a value to the session storage
	 *		$value = Session::put('name', 'Taylor');
	 *
	 *		// Equivalent statement using the "instance" method
	 *		$value = Session::instance()->put('name', 'Taylor');
	 * </code>
	 */
	public static function __callStatic($method, $parameters)
	{
		return call_user_func_array(array(static::instance(), $method), $parameters);
	}

}
{'fraction_non_alphanumeric': 0.13966585320067582, 'fraction_numerical': 0.0, 'mean_word_length': 3.417910447761194, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 17, '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': '2442075', 'n_tokens_mistral': 1778, 'n_tokens_neox': 1544, 'n_words': 499}