/** * @param ServerRequestInterface $request * @return array */ protected function match(ServerRequestInterface $request) { return array_filter($this->routes->getRoutes(), function (Route $route) use($request) { $match = $route->matches($request); if (false !== $match) { return $route->setParams($match); } }); }
public function testCollectionAddsRoutes() { $collection = new Collection(); $collection->get('/', 'index', function () { return 'Hello, World!'; }); $this->assertCount(1, $collection->getRoutes()); $collection->post('/hello-again', 'hello', function () { return 'Hello again, world!'; }); $this->assertCount(2, $collection->getRoutes()); }