src/Application/App.php
public function addRoute(
        $path,
        $middlewares = null,
        string $method = null,
        string $name = null
    ): Route {
        if (!$path instanceof Route && null === $middlewares) {
            throw new \InvalidArgumentException('Invalid route config');
        }

        if ($path instanceof Route) {
            $route = $path;
        }

        if (!isset($route)) {
            $path = $this->groupPath . $path;

            if (count($this->groupMiddleware) > 0) {
                $temp = $middlewares;
                $middlewares = $this->groupMiddleware;

                array_push($middlewares, $temp);
            }

            $middlewares = $this->buildMiddleware($middlewares);
            $route = new Route($path, $middlewares, $method, $name);
        }

        $this->router->addRoute($route);

        $this->log(
            $this->container,
            sprintf(
                'App::addRoute - Add route %s %s (%s)',
                implode(',', $route->getMethod()),
                $route->getPath(),
                null === $route->getName() ? 'no name' : $route->getName()
            )
        );

        return $route;
    }
public function addRoute(
        $path,
        $middlewares = null,
        string $method = null,
        string $name = null
    ): Route {
        if (!$path instanceof Route && null === $middlewares) {
            throw new \InvalidArgumentException('Invalid route config');
        }

        if ($path instanceof Route) {
            $route = $path;
        }

        if (!isset($route)) {
            $path = $this->groupPath . $path;

            if (count($this->groupMiddleware) > 0) {
                $temp = $middlewares;
                $middlewares = $this->groupMiddleware;

                array_push($middlewares, $temp);
            }

            $middlewares = $this->buildMiddleware($middlewares);
            $route = new Route($path, $middlewares, $method, $name);
        }

        $this->router->addRoute($route);

        $this->log(
            $this->container,
            sprintf(
                'App::addRoute - Add route %s %s (%s)',
                implode(',', $route->getMethod()),
                $route->getPath(),
                null === $route->getName() ? 'no name' : $route->getName()
            )
        );

        return $route;
    }
Add route on router.

@param string      $path
@param null        $middlewares
@param string|null $method
@param string|null $name

@throws \InvalidArgumentException

@return Route