<commit_before><?php

	namespace Smooth\Core;

	use Smooth\Loader\Loader;
	use Smooth\Routing\Dispatcher;
	use Smooth\Routing\Routes;

	class Router
	{

		/**
		 * [$class description]
		 * @var [type]
		 */
		protected $class;
		/**
		 * [$method description]
		 * @var string
		 */
		protected $method;

		/**
		 * [$defaultController description]
		 * @var [type]
		 */
		protected $defaultController;

		/**
		 * [$path description]
		 * @var [type]
		 */
		protected $path;

		/**
		 * [$uri description]
		 * @var [type]
		 */
		protected $uri;
		
			/**
		 * [$controller description]
		 * @var [type]
		 */
		protected $controller;

		/**
		 * [__construct description]
		 * @param string $uri [description]
		 */
		public function __construct($uri)
		{
			$this->uri = $uri;
			$this->defaultController = BASECONTROLLER;
			if( is_object( $uri ) )
				exit('There is no existing controller method!');

			$this->path = explode('/', $uri);

			$this->setController();
			$this->setMethod();
			$this->checkRouting();

			$this->class = Loader::controller( $this->controller );

		}

		/**
		 * [setController description]
		 * @return string [description]
		 */
		public function setController()
		{
			return ( empty( $this->path[2] ) ) ? $this->controller = $this->defaultController : $this->controller = $this->path[2];
		}

		/**
		 * [setMethod description]
		 * @return string [description]
		 */
		public function setMethod()
		{
			return ( empty( $this->path[3] ) ) ? $this->method = 'index' : $this->method = $this->path[3];
		}

		/**
		 * [checkRouting description]
		 * @return [type] [description]
		 */
		public function checkRouting()
		{	
			$route = Routes::getRoutes();
			if( count( $route ) > 0 )
			{
				extract($route);
				if( strtolower($this->controller) === strtolower($controller) and strtolower($this->method) === strtolower($method) )
				{
					$n = explode('/', $redirect);
					$this->controller = $n[0];
					$this->method = $n[1];
				}
			}
		}


		/**
		 * [getController description]
		 * @param  [type] $controller [description]
		 * @return string             [description]
		 */
		public function getController( $controller )
		{
			return $this->controller;
		}

		/**
		 * [getMethod description]
		 * @return string [description]
		 */
		public function getMethod()
		{
			return $this->method;
		}

		/**
		 * [getResponse description]
		 * @return array [description]
		 */
		public function getResponse()
		{
			return array(
					'controller' => $this->controller, 
					'method' => $this->method,
					'path' => $this->path,
					'class' => Loader::controller( $this->controller )
				);	
		}

	}

<commit_msg>Update Router.php<commit_after><?php

	namespace Smooth\Core;

	use Smooth\Loader\Loader;
	use Smooth\Routing\Dispatcher;
	use Smooth\Routing\Routes;
	use Smooth\Controller;

	class Router
	{

		/**
		 * [$class description]
		 * @var [type]
		 */
		protected $class;
		/**
		 * [$method description]
		 * @var string
		 */
		protected $method;

		/**
		 * [$defaultController description]
		 * @var [type]
		 */
		protected $defaultController;

		/**
		 * [$path description]
		 * @var [type]
		 */
		protected $path;

		/**
		 * [$uri description]
		 * @var [type]
		 */
		protected $uri;
		
			/**
		 * [$controller description]
		 * @var [type]
		 */
		protected $controller;

		protected $route;

		/**
		 * [__construct description]
		 * @param string $uri [description]
		 */
				public function __construct($uri)
		{
			$this->uri = $uri;
			$this->defaultController = BASECONTROLLER;
			$data['content'] = NOTFOUND;
			if( is_object( $uri ) )
			{
				Controller::render('includes/template', compact($data));
				exit();
			}

			$this->count = substr_count($uri, '/');
			
			$this->path = explode('/', $uri);

			$route = array_diff($this->path, explode('/', URL));

			foreach ($route as $key => $value) 
			{
				$this->route[] = $value;
			}

			$this->setController();
			$this->setMethod();
			$this->checkRouting();

			$this->class = Loader::controller( $this->controller );

		}

		/**
		 * [setController description]
		 * @return string [description]
		 */
		public function setController()
		{
			return ( empty( $this->route[0] ) ) ? $this->controller = $this->defaultController : $this->controller = $this->route[0];
		}

		/**
		 * [setMethod description]
		 * @return string [description]
		 */
		public function setMethod()
		{
			return ( empty( $this->route[1] ) ) ? $this->method = 'index' : $this->method = $this->route[1];
		}
		/**
		 * [checkRouting description]
		 * @return [type] [description]
		 */
		public function checkRouting()
		{	
			$route = Routes::getRoutes();
			if( count( $route ) > 0 )
			{
				extract($route);
				if( strtolower($this->controller) === strtolower($controller) and strtolower($this->method) === strtolower($method) )
				{
					$n = explode('/', $redirect);
					$this->controller = $n[0];
					$this->method = $n[1];
				}
			}
		}


		/**
		 * [getController description]
		 * @param  [type] $controller [description]
		 * @return string             [description]
		 */
		public function getController( $controller )
		{
			return $this->controller;
		}

		/**
		 * [getMethod description]
		 * @return string [description]
		 */
		public function getMethod()
		{
			return $this->method;
		}

		/**
		 * [getResponse description]
		 * @return array [description]
		 */
		public function getResponse()
		{
			return array(
					'controller' => $this->controller, 
					'method' => $this->method,
					'path' => $this->path,
					'class' => Loader::controller( $this->controller )
				);	
		}

	}


{'fraction_non_alphanumeric': 0.17728482697426798, 'fraction_numerical': 0.002484472049689441, 'mean_word_length': 2.752330226364847, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 71, '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': '6162874', 'n_tokens_mistral': 2255, 'n_tokens_neox': 1777, 'n_words': 377}