src/Router.php
public function group(array $attributes, Closure $routes): Router
    {
        // Backup current properties
        $oldName = $this->currentName;
        $oldMiddleware = $this->currentMiddleware;
        $oldNamespace = $this->currentNamespace;
        $oldPrefix = $this->currentPrefix;
        $oldDomain = $this->currentDomain;

        $this->currentName = null;

        // Set middleware for the group
        if (isset($attributes[GroupAttributes::MIDDLEWARE])) {
            if (is_array($attributes[Route::MIDDLEWARE]) == false) {
                $attributes[GroupAttributes::MIDDLEWARE] = [$attributes[GroupAttributes::MIDDLEWARE]];
            }

            $this->currentMiddleware = array_merge($attributes[GroupAttributes::MIDDLEWARE], $this->currentMiddleware);
        }

        // Set namespace for the group
        if (isset($attributes[GroupAttributes::NAMESPACE])) {
            $this->currentNamespace = $attributes[GroupAttributes::NAMESPACE];
        }

        // Set prefix for the group
        if (isset($attributes[GroupAttributes::PREFIX])) {
            $this->currentPrefix = $this->currentPrefix.$attributes[GroupAttributes::PREFIX];
        }

        // Set domain for the group
        if (isset($attributes[GroupAttributes::DOMAIN])) {
            $this->currentDomain = $attributes[GroupAttributes::DOMAIN];
        }

        // Run the group body closure
        call_user_func($routes, $this);

        // Restore properties
        $this->currentName = $oldName;
        $this->currentDomain = $oldDomain;
        $this->currentPrefix = $oldPrefix;
        $this->currentMiddleware = $oldMiddleware;
        $this->currentNamespace = $oldNamespace;

        return $this;
    }
public function group(array $attributes, Closure $routes): Router
    {
        // Backup current properties
        $oldName = $this->currentName;
        $oldMiddleware = $this->currentMiddleware;
        $oldNamespace = $this->currentNamespace;
        $oldPrefix = $this->currentPrefix;
        $oldDomain = $this->currentDomain;

        $this->currentName = null;

        // Set middleware for the group
        if (isset($attributes[GroupAttributes::MIDDLEWARE])) {
            if (is_array($attributes[Route::MIDDLEWARE]) == false) {
                $attributes[GroupAttributes::MIDDLEWARE] = [$attributes[GroupAttributes::MIDDLEWARE]];
            }

            $this->currentMiddleware = array_merge($attributes[GroupAttributes::MIDDLEWARE], $this->currentMiddleware);
        }

        // Set namespace for the group
        if (isset($attributes[GroupAttributes::NAMESPACE])) {
            $this->currentNamespace = $attributes[GroupAttributes::NAMESPACE];
        }

        // Set prefix for the group
        if (isset($attributes[GroupAttributes::PREFIX])) {
            $this->currentPrefix = $this->currentPrefix.$attributes[GroupAttributes::PREFIX];
        }

        // Set domain for the group
        if (isset($attributes[GroupAttributes::DOMAIN])) {
            $this->currentDomain = $attributes[GroupAttributes::DOMAIN];
        }

        // Run the group body closure
        call_user_func($routes, $this);

        // Restore properties
        $this->currentName = $oldName;
        $this->currentDomain = $oldDomain;
        $this->currentPrefix = $oldPrefix;
        $this->currentMiddleware = $oldMiddleware;
        $this->currentNamespace = $oldNamespace;

        return $this;
    }
Group routes with the given attributes

@param array $attributes
@param Closure $routes
@return $this