original_string: public function scope($path, $params, $callback = null)
      {
          if (is_callable($params)) {
              $callback = $params;
              $params = [];
          }
          if (!is_callable($callback)) {
              $msg = 'Need a callable function/object to connect routes.';
              throw new InvalidArgumentException($msg);
          }
  
          if ($this->_path !== '/') {
              $path = $this->_path . $path;
          }
          $namePrefix = $this->_namePrefix;
          if (isset($params['_namePrefix'])) {
              $namePrefix .= $params['_namePrefix'];
          }
          unset($params['_namePrefix']);
  
          $params += $this->_params;
          $builder = new static($this->_collection, $path, $params, [
              'routeClass' => $this->_routeClass,
              'extensions' => $this->_extensions,
              'namePrefix' => $namePrefix,
              'middleware' => $this->middleware,
          ]);
          $callback($builder);
      }
code: public function scope($path, $params, $callback = null)
      {
          if (is_callable($params)) {
              $callback = $params;
              $params = [];
          }
          if (!is_callable($callback)) {
              $msg = 'Need a callable function/object to connect routes.';
              throw new InvalidArgumentException($msg);
          }
  
          if ($this->_path !== '/') {
              $path = $this->_path . $path;
          }
          $namePrefix = $this->_namePrefix;
          if (isset($params['_namePrefix'])) {
              $namePrefix .= $params['_namePrefix'];
          }
          unset($params['_namePrefix']);
  
          $params += $this->_params;
          $builder = new static($this->_collection, $path, $params, [
              'routeClass' => $this->_routeClass,
              'extensions' => $this->_extensions,
              'namePrefix' => $namePrefix,
              'middleware' => $this->middleware,
          ]);
          $callback($builder);
      }
code_tokens: public function scope ( $ path , $ params , $ callback = null ) { if ( is_callable ( $ params ) ) { $ callback = $ params ; $ params = [ ] ; } if ( ! is_callable ( $ callback ) ) { $ msg = 'Need a callable function/object to connect routes.' ; throw new InvalidArgumentException ( $ msg ) ; } if ( $ this -> _path !== '/' ) { $ path = $ this -> _path . $ path ; } $ namePrefix = $ this -> _namePrefix ; if ( isset ( $ params [ '_namePrefix' ] ) ) { $ namePrefix .= $ params [ '_namePrefix' ] ; } unset ( $ params [ '_namePrefix' ] ) ; $ params += $ this -> _params ; $ builder = new static ( $ this -> _collection , $ path , $ params , [ 'routeClass' => $ this -> _routeClass , 'extensions' => $ this -> _extensions , 'namePrefix' => $ namePrefix , 'middleware' => $ this -> middleware , ] ) ; $ callback ( $ builder ) ; }
docstring: Create a new routing scope.
  
  Scopes created with this method will inherit the properties of the scope they are
  added to. This means that both the current path and parameters will be appended
  to the supplied parameters.
  
  @param string $path The path to create a scope for.
  @param array|callable $params Either the parameters to add to routes, or a callback.
  @param callable|null $callback The callback to invoke that builds the plugin routes.
  Only required when $params is defined.
  @return void
  @throws \InvalidArgumentException when there is no callable parameter.
docstring_tokens: Create a new routing scope .