<commit_before><?php
require_once('Routes.php');
/**
 * This class is responsible for routing url's to the apropriate controllers and functions.
 * It handles url's like "foo/foo/foo". In a url like "http://mydomain.com/foo/foo?foo=foo"
 * the address "http://mydomain.com" and the GET variables "?foo=foo" should be filtered
 * before passing them to the router.
 * 
 * @author j.smit <<EMAIL>>
 */
class Router
{	
	/**
	 * Routes are stored in a protedted variable so they can be tested easily with
	 * a custom routes-set for testing.
	 * 
	 * @var $routes[]
	 */
	protected $routes;
	
	/**
	 * Returns the right Route given a stripped url (/your/route/here)
	 * 
	 * @param string $url, contains the full url
	 * @return Route
	 */
	protected function getRouteForUrl($url)
	{
		$route = NULL;

		for($i = sizeof($this->routes)-1; $i >= 0; $i--)
		{
			if(ereg($this->routes[$i]['pattern'], $url))
			{
				$route = $this->routes[$i];
				break;
			}
		}
		
		if($route == NULL)
		{
			throw new Exception('Ivalid url, unable to get route.');
		}
		
		return $route;
	}
	
	/**
	 * Launches off the router and sets up intial values. These can be overidden in the test classes.
	 */
	public static function dispatch()
	{
		$this->routes = Routes::$routes;
	}
}
?><commit_msg>added  to the dispatch method<commit_after><?php
require_once('Routes.php');
/**
 * This class is responsible for routing url's to the apropriate controllers and functions.
 * It handles url's like "foo/foo/foo". In a url like "http://mydomain.com/foo/foo?foo=foo"
 * the address "http://mydomain.com" and the GET variables "?foo=foo" should be filtered
 * before passing them to the router.
 * 
 * @author j.smit <<EMAIL>>
 */
class Router
{	
	/**
	 * Routes are stored in a protedted variable so they can be tested easily with
	 * a custom routes-set for testing.
	 * 
	 * @var $routes[]
	 */
	protected $routes;
	
	/**
	 * Returns the right Route given a stripped url (/your/route/here)
	 * 
	 * @param string $url, contains the full url
	 * @return Route
	 */
	protected function getRouteForUrl($url)
	{
		$route = NULL;

		for($i = sizeof($this->routes)-1; $i >= 0; $i--)
		{
			if(ereg($this->routes[$i]['pattern'], $url))
			{
				$route = $this->routes[$i];
				break;
			}
		}
		
		if($route == NULL)
		{
			throw new Exception('Ivalid url, unable to get route.');
		}
		
		return $route;
	}
	
	/**
	 * Launches off the router and sets up intial values. These can be overidden in the test classes.
	 */
	public static function dispatch($url)
	{
		$this->routes = Routes::$routes;
		$route = $this->getRouteFromUrl($url);
	}
}
?>
{'fraction_non_alphanumeric': 0.14772292384232683, 'fraction_numerical': 0.0015308075009567547, 'mean_word_length': 3.1230283911671926, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 20, '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': '1594961', 'n_tokens_mistral': 944, 'n_tokens_neox': 858, 'n_words': 282}