original_string: public function prefix($name, $params = [], callable $callback = null)
      {
          if ($callback === null) {
              if (!is_callable($params)) {
                  throw new InvalidArgumentException('A valid callback is expected');
              }
              $callback = $params;
              $params = [];
          }
          $name = Inflector::underscore($name);
          $path = '/' . $name;
          if (isset($params['path'])) {
              $path = $params['path'];
              unset($params['path']);
          }
          if (isset($this->_params['prefix'])) {
              $name = $this->_params['prefix'] . '/' . $name;
          }
          $params = array_merge($params, ['prefix' => $name]);
          $this->scope($path, $params, $callback);
      }
code: public function prefix($name, $params = [], callable $callback = null)
      {
          if ($callback === null) {
              if (!is_callable($params)) {
                  throw new InvalidArgumentException('A valid callback is expected');
              }
              $callback = $params;
              $params = [];
          }
          $name = Inflector::underscore($name);
          $path = '/' . $name;
          if (isset($params['path'])) {
              $path = $params['path'];
              unset($params['path']);
          }
          if (isset($this->_params['prefix'])) {
              $name = $this->_params['prefix'] . '/' . $name;
          }
          $params = array_merge($params, ['prefix' => $name]);
          $this->scope($path, $params, $callback);
      }
code_tokens: public function prefix ( $ name , $ params = [ ] , callable $ callback = null ) { if ( $ callback === null ) { if ( ! is_callable ( $ params ) ) { throw new InvalidArgumentException ( 'A valid callback is expected' ) ; } $ callback = $ params ; $ params = [ ] ; } $ name = Inflector :: underscore ( $ name ) ; $ path = '/' . $ name ; if ( isset ( $ params [ 'path' ] ) ) { $ path = $ params [ 'path' ] ; unset ( $ params [ 'path' ] ) ; } if ( isset ( $ this -> _params [ 'prefix' ] ) ) { $ name = $ this -> _params [ 'prefix' ] . '/' . $ name ; } $ params = array_merge ( $ params , [ 'prefix' => $ name ] ) ; $ this -> scope ( $ path , $ params , $ callback ) ; }
docstring: Add prefixed routes.
  
  This method creates a scoped route collection that includes
  relevant prefix information.
  
  The $name parameter is used to generate the routing parameter name.
  For example a path of `admin` would result in `'prefix' => 'admin'` being
  applied to all connected routes.
  
  You can re-open a prefix as many times as necessary, as well as nest prefixes.
  Nested prefixes will result in prefix values like `admin/api` which translates
  to the `Controller\Admin\Api\` namespace.
  
  If you need to have prefix with dots, eg: '/api/v1.0', use 'path' key
  for $params argument:
  
  ```
  $route->prefix('api', function($route) {
  $route->prefix('v10', ['path' => '/v1.0'], function($route) {
  // Translates to `Controller\Api\V10\` namespace
  });
  });
  ```
  
  @param string $name The prefix name to use.
  @param array|callable $params An array of routing defaults to add to each connected route.
  If you have no parameters, this argument can be a callable.
  @param callable|null $callback The callback to invoke that builds the prefixed routes.
  @return void
  @throws \InvalidArgumentException If a valid callback is not passed
docstring_tokens: Add prefixed routes .