@param RouterAbstract $router
@param string         $function

@return Meta\Data
336275
private function generateMetaDataForRouter(RouterAbstract $router, string $function): Meta\Data
    {
        $data = new Meta\Data(get_class($router), $function);

        foreach ($router->getData() as $key => $details)
        {
            $data->map(
                '\\' . $key,
                true,
                '\\' . $details['class'] . '::class',
                false
            );
        }

        return $data;
    }
713245
public function get($function)
    {
        $this->toDispatch[] = $function;

        if (is_null($this->dataProvider)) {
            $this->currentData = null;
            $this->dispatchData();
            return;
        }

        if (is_null($this->currentData)) {
            if (!$this->callMade) {
                $this->callMade = true;
                $this->dataProvider->request();
            }
            return;
        }

        $this->dispatchData();
    }
500812
function update($route) {
        $route->pattern = $this->parser->trimPath($route->pattern);
        return parent::update($route);
    }
950
protected function dispatchToRouter() : Closure
    {
        return function ($request) {
            return $this->router->setContainer($this->container)->dispatch($request);
        };
    }
207765
public function map($method, $route, $handler)
    {
        $this['router']->map($method, $route, $handler);

        return $this;
    }
28878
public function getPager($route, $routePrm, $total, $page, $nbPerPage)
    {
        return new Pager($this, $route, $routePrm, $total, $page, $nbPerPage);
    }
999359
private function handle($routes, $fireAfterRoutingCallback = false)
    {
        // Counter to keep track of the number of routes we've handled
        $handledRequest = 0;

        $i = 0;
        // Loop all routes
        foreach ($routes as $route) {
            if ($matches = $this->isPatternMatches($route['pattern'], true)) {
                if ($this->middleware) {
                    $this->handleMiddleware();
                }

                // Extract the matched URL (and only the parameters)
                $params = $this->extractParams($matches);
                array_unshift($params, $this);

                // call the handling function with the URL
                $this->handledRoute = call_user_func_array($route['fn'], $params);
                $this->container->set('response', $this->handledRoute);

                $handledRequest++;

                // If we need to quit, then quit
                if ($fireAfterRoutingCallback) {
                    // If a route was handled, perform the finish callback (if any)
                    $this->handle($this->afterRouter);
                }
            }
            $i++;
        }

        // Return the number of routes handled
        return $handledRequest;
    }
1319404
protected function getRaw($key, $function = null)
    {
        if (!$this->isString($key)) {
            /* If $key is not valid string throws InvalidArgumentException */
            throw new InvalidArgumentException('Cache key must be not empty string');
        }

        $item = $this->getCachedItem($key);

        if ($item && !$this->isExpired($item)) {
            return !is_null($function) ? $function($item->get()) : $item->get();
        }
    }
84327
public function run(Router $router)
    {
        $middleware = new RouterMiddleware($router);
        $middleware->setErrorHandler($router->getErrorHandler())
            ->setNotFound($router->getNotFoundHandler());

        $this->middleware = array_merge([$middleware], $this->middleware);

        $next = null;
        $stack = new \SplDoublyLinkedList();
        foreach ($this->middleware as $callback) {
            if ($stack->count() > 0) {
                $next = $stack->top();
            }
            $stack->push(function ($request, $response) use ($callback, $next) {
                return call_user_func($callback, $request, $response, $next);
            });
        }

        $server = Server::createServer(function ($request, $response) use ($stack) {
            /**
             * @var $request \Zend\Diactoros\Request
             * @var $response \Zend\Diactoros\Response
             * @var $stream \Psr\Http\Message\StreamInterface
             */
            if ($request->getMethod() === 'TRACE') {
                $stream = $response->getBody();
                $stream->write(sprintf(
                    '%s %s' . PHP_EOL,
                    $request->getMethod(),
                    $request->getUri()->getPath()
                ));
                foreach ($request->getHeaders() as $header => $values) {
                    foreach ($values as $value) {
                        $stream->write(sprintf('%s: %s' . PHP_EOL, $header, $value));
                    }
                }
            }

            $stack->setIteratorMode(\SplDoublyLinkedList::IT_MODE_LIFO);
            if ($stack !== null && $request->getMethod() !== 'TRACE') {
                $response = call_user_func($stack->top(), $request, $response);
            }

            return $response;
        }, $_SERVER, $_GET, $_POST, $_COOKIE, $_FILES);
        $server->listen();
    }
802389
public function addRoute($uri, $callback, $delimiter = Map::DEFAULT_URL_DELIMITER)
    {
        try {
            /**
             * if the uri is empty throw an exception
             */
            if (empty($uri)) {
                throw new RouteException(sprintf(_('There is no Route entered %s'), $uri));
            }

            // class for mapping
            $route = new Map($uri, $callback, $delimiter);
            $this->rootNode->appendToBranch($uri, $route, Map::DEFAULT_URL_DELIMITER);

        } catch (RouteException $e) {
            throw $e;
        }

    }
557051
def run_with_router(func, *args, **kwargs):
    
    broker = mitogen.master.Broker()
    router = mitogen.master.Router(broker)
    try:
        return func(router, *args, **kwargs)
    finally:
        broker.shutdown()
        broker.join()
244394
function Router_trim(str, strip) {
        if (!Type.isString(str)) {
            return str;
        }
        str = str.trim();
        if (strip) {
            str = str.replace(core.createRegex('^' + strip), '');
            str = str.replace(core.createRegex(strip + '$'), '');
        }
        return str;
    }
444604
public function route(RouterInterface $router, string $path, string $filter, array &$vars) : bool
    {
        // dispatch if no paths remain in buffer(means last node)
        if (empty($path)){
            if (empty($filter)){
                $event = $this->filters['*'] ?? '';
            }
            else{
                $event = $this->filters[$filter] ?? $this->filters['*'] ?? '';
                if(!$event){
                    foreach($this->filters as $filter => $e){
                        if ($filter === self::FILTER_KEY_DEFAULT){
                            $event = $e;
                        }
                    }
                }
            }
            if (!empty($event)){
                $router->dispatch($vars, $event);
                return true;
            }
        }
        return parent::route($router, $path, $filter, $vars);
    }
1086208
public function route(string $route_url, string $filter) : bool
    {
        $vars = [];
        if ($this->root_node->route($this, $route_url, $filter, $vars))
        {
            return true;
        }
        return $this->dispatch( [], self::EVENT_NOT_FOUND );
    }
1216856
public function map(Router $router)
    {
        $router->group(array('namespace' => $this->namespace), function ($router)
        {
            $basePath = $this->guessPackageRoutesPath();

            if (is_readable($path = $basePath .DS .'Api.php')) {
                $router->group(array('prefix' => 'api', 'middleware' => 'api'), function ($router) use ($path)
                {
                    require $path;
                });
            }

            if (is_readable($path = $basePath .DS .'Web.php')) {
                $router->group(array('middleware' => 'web'), function ($router) use ($path)
                {
                    require $path;
                });
            }
        });
    }
23922
private function splitRoutesIntoSections(IRouter $router): array
	{
		$routes = [];
		$sections = [];
		$fileName = 1;

		if ($router instanceof ApiRoute) {
			$routes = [$router];
		} elseif ($router instanceof \IteratorAggregate) {
			$routes = $this->getApiRoutesFromIterator($router);
		}

		foreach ($routes as $route) {
			if ($route->getSection()) {
				if (empty($sections[$route->getSection()])) {
					$sections[$route->getSection()] = [];
				}

				$sections[$route->getSection()][$fileName++] = $route;
			} else {
				$sections[$fileName++] = $route;
			}
		}

		return $sections;
	}
1152301
private function GetControllerObject(\Puzzlout\Framework\Core\Router $router) {
        $controllerName = $this->BuildControllerName($router->currentRoute());
        $FrameworkControllers = "\Puzzlout\Framework\Generated\FrameworkControllers";
        $ApplicationControllers = "\Applications\\" .
                "APP_NAME" .
                "\Generated\\" .
                "APP_NAME" . "Controllers";

        $controllerClassName = $this->FindControllerClassName(
                $controllerName, $FrameworkControllers, $ApplicationControllers, $router
        );
        return $this->InstanciateController($controllerClassName, $router->currentRoute());
    }