system/Config/Services.php
public static function router(RouteCollectionInterface $routes = null, bool $getShared = true)
	{
		if ($getShared)
		{
			return static::getSharedInstance('router', $routes);
		}

		if (empty($routes))
		{
			$routes = static::routes(true);
		}

		return new Router($routes);
	}
public static function router(RouteCollectionInterface $routes = null, bool $getShared = true)
	{
		if ($getShared)
		{
			return static::getSharedInstance('router', $routes);
		}

		if (empty($routes))
		{
			$routes = static::routes(true);
		}

		return new Router($routes);
	}
The Router class uses a RouteCollection's array of routes, and determines
the correct Controller and Method to execute.

@param \CodeIgniter\Router\RouteCollectionInterface $routes
@param boolean                                      $getShared

@return \CodeIgniter\Router\Router