Zend\Expressive\Application::checkForDuplicateRoute PHP Method

checkForDuplicateRoute() private method

Checks if a route with the same name or path exists already in the list; if so, and it responds to any of the $methods indicated, raises a DuplicateRouteException indicating a duplicate route.
private checkForDuplicateRoute ( string $path, null | array $methods = null )
$path string
$methods null | array
    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');
        }
    }