private function checkForDuplicateRoute($path, $methods = null)
{
if (null === $methods) {
$methods = Router\Route::HTTP_METHOD_ANY;
}
$matches = array_filter($this->routes, function (Router\Route $route) use($path, $methods) {
if ($path !== $route->getPath()) {
return false;
}
if ($methods === Router\Route::HTTP_METHOD_ANY) {
return true;
}
return array_reduce($methods, function ($carry, $method) use($route) {
return $carry || $route->allowsMethod($method);
}, false);
});
if (count($matches) > 0) {
throw new Exception\DuplicateRouteException('Duplicate route detected; same name or path, and one or more HTTP methods intersect');
}
}