Beispiel #1
0
 /**
  * @inheritDoc
  */
 public function match(ServerRequestInterface $request, RouteCollectionContract $routeCollection) : RouteContract
 {
     $routes = $routeCollection->getRoutes();
     $parsedRouteData = $this->parser->parse($routes);
     $dispatcher = $this->fastrouteDispatcherFactory->create($parsedRouteData);
     $match = $dispatcher->dispatch($request->getMethod(), $request->getUri()->getPath());
     switch ($match[0]) {
         case $dispatcher::FOUND:
             /** @var RouteContract $route */
             list(, $route, $variables) = $match;
             return $route->withVariables($variables);
         case $dispatcher::METHOD_NOT_ALLOWED:
             throw new NotAllowedException($match[1]);
         default:
             throw new NotFoundException($request->getMethod(), $request->getUri()->getPath());
     }
 }
Beispiel #2
0
 function let(RouteParser $parser, FastrouteDispatcherFactory $factory, Route $route, Dispatcher $dispatcher)
 {
     $parser->parse(Argument::containing($route->getWrappedObject()))->willReturn(['parsed']);
     $factory->create(['parsed'])->willReturn($dispatcher);
     $this->beConstructedWith($parser, $factory);
 }