<commit_before><?php

namespace CatLab\OpenIDClient;

use CatLab\OpenIDClient\Mappers\UserMapper;
use CatLab\OpenIDClient\Models\User;
use Neuron\Application;
use Neuron\Exceptions\DataNotSet;
use Neuron\Exceptions\ExpectedType;
use Neuron\MapperFactory;
use Neuron\Net\Request;
use Neuron\Net\Response;
use Neuron\Router;
use Neuron\URLBuilder;

class Module
	implements \Neuron\Interfaces\Module {

	private $routepath;

	/**
	 * Set template paths, config vars, etc
	 * @param string $routepath The prefix that should be added to all route paths.
	 * @return void
	 */
	public function initialize ($routepath)
	{
		$this->routepath = $routepath;

		// Set session variable
		Application::getInstance ()->on ('dispatch:before', array ($this, 'setRequestUser'));

		// Set the global user mapper, unless one is set already
		Application::getInstance ()->on ('dispatch:first', array ($this, 'setUserMapper'));
	}

	/**
	 * Register the routes required for this module.
	 * @param Router $router
	 * @return void
	 */
	public function setRoutes (Router $router)
	{
		$router->match ('GET|POST', $this->routepath . '/login', '\CatLab\OpenIDClient\Controllers\LoginController@login');
		$router->match ('GET|POST', $this->routepath . '/login/next', '\CatLab\OpenIDClient\Controllers\LoginController@next');

		$router->get ($this->routepath . '/status', '\CatLab\OpenIDClient\Controllers\LoginController@status');
	}

	public function setUserMapper ()
	{
		try {
			$mapper = MapperFactory::getUserMapper ();
			ExpectedType::check ($mapper, UserMapper::class);
		}
		catch (DataNotSet $e)
		{
			MapperFactory::getInstance ()->setMapper ('user', new UserMapper ());
		}
	}

	/**
	 * Login a specific user
	 * @param Request $request
	 * @param User $user<commit_msg>Dum dum dum. Adding logout method.<commit_after><?php

namespace CatLab\OpenIDClient;

use CatLab\OpenIDClient\Mappers\UserMapper;
use CatLab\OpenIDClient\Models\User;
use Neuron\Application;
use Neuron\Exceptions\DataNotSet;
use Neuron\Exceptions\ExpectedType;
use Neuron\MapperFactory;
use Neuron\Net\Request;
use Neuron\Net\Response;
use Neuron\Router;
use Neuron\URLBuilder;

class Module
	implements \Neuron\Interfaces\Module {

	private $routepath;

	/**
	 * Set template paths, config vars, etc
	 * @param string $routepath The prefix that should be added to all route paths.
	 * @return void
	 */
	public function initialize ($routepath)
	{
		$this->routepath = $routepath;

		// Set session variable
		Application::getInstance ()->on ('dispatch:before', array ($this, 'setRequestUser'));

		// Set the global user mapper, unless one is set already
		Application::getInstance ()->on ('dispatch:first', array ($this, 'setUserMapper'));
	}

	/**
	 * Register the routes required for this module.
	 * @param Router $router
	 * @return void
	 */
	public function setRoutes (Router $router)
	{
		$router->match ('GET|POST', $this->routepath . '/login', '\CatLab\OpenIDClient\Controllers\LoginController@login');
		$router->match ('GET|POST', $this->routepath . '/login/next', '\CatLab\OpenIDClient\Controllers\LoginController@next');

		$router->get ($this->routepath . '/logout', '\CatLab\OpenIDClient\Controllers\LoginController@logout');

		$router->get ($this->routepath . '/status', '\CatLab\OpenIDClient\Controllers\LoginController@status');
	}

	public function setUserMapper ()
	{
		try {
			$mapper = MapperFactory::getUserMapper ();
			ExpectedType::check ($mapper, UserMapper::class);
		}
		catch (DataNotSet $e)
		{
			MapperFactory::getInstance ()->setMapper ('user', new UserMapper ());
		}
	}

	/**
	 * Login a specific user
	 * @param Request $request
	 * @param User $user
{'fraction_non_alphanumeric': 0.1425054704595186, 'fraction_numerical': 0.0, 'mean_word_length': 4.557750759878419, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, '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': '7201830', 'n_tokens_mistral': 1252, 'n_tokens_neox': 1116, 'n_words': 286}