original_string: public function add($method, $url = null, $handler = null) : RouterInterface
      {
          $temp = [ 'method' => [ 'GET', 'POST' ], 'url' => '', 'handler' => null ];
          foreach (func_get_args() as $arg) {
              if (is_callable($arg)) {
                  $temp['handler'] = $arg;
              } else if (in_array($arg, ['GET', 'HEAD', 'POST', 'PATCH', 'DELETE', 'PUT', 'OPTIONS', 'REPORT'])) {
                  $temp['method'] = $arg;
              } else {
                  $temp['url'] = $arg;
              }
          }
          list($method, $url, $handler) = array_values($temp);
  
          if (!$url && $this->prefix) {
              $url = $this->prefix;
          } else {
              if (!$url) {
                  $url = '{**}';
              }
              $url = $this->prefix.$url;
          }
  
          if (!$method) {
              $method = ['GET','POST'];
          }
          if (!is_array($method)) {
              $method = [$method];
          }
          if (!is_callable($handler)) {
              throw new RouterException('No valid handler found');
          }
  
          foreach ($method as $m) {
              if (!isset($this->routes[$m])) {
                  $this->routes[$m] = [];
              }
              $this->routes[$m][$url] = $handler;
          }
  
          return $this;
      }
code: public function add($method, $url = null, $handler = null) : RouterInterface
      {
          $temp = [ 'method' => [ 'GET', 'POST' ], 'url' => '', 'handler' => null ];
          foreach (func_get_args() as $arg) {
              if (is_callable($arg)) {
                  $temp['handler'] = $arg;
              } else if (in_array($arg, ['GET', 'HEAD', 'POST', 'PATCH', 'DELETE', 'PUT', 'OPTIONS', 'REPORT'])) {
                  $temp['method'] = $arg;
              } else {
                  $temp['url'] = $arg;
              }
          }
          list($method, $url, $handler) = array_values($temp);
  
          if (!$url && $this->prefix) {
              $url = $this->prefix;
          } else {
              if (!$url) {
                  $url = '{**}';
              }
              $url = $this->prefix.$url;
          }
  
          if (!$method) {
              $method = ['GET','POST'];
          }
          if (!is_array($method)) {
              $method = [$method];
          }
          if (!is_callable($handler)) {
              throw new RouterException('No valid handler found');
          }
  
          foreach ($method as $m) {
              if (!isset($this->routes[$m])) {
                  $this->routes[$m] = [];
              }
              $this->routes[$m][$url] = $handler;
          }
  
          return $this;
      }
code_tokens: public function add ( $ method , $ url = null , $ handler = null ) : RouterInterface { $ temp = [ 'method' => [ 'GET' , 'POST' ] , 'url' => '' , 'handler' => null ] ; foreach ( func_get_args ( ) as $ arg ) { if ( is_callable ( $ arg ) ) { $ temp [ 'handler' ] = $ arg ; } else if ( in_array ( $ arg , [ 'GET' , 'HEAD' , 'POST' , 'PATCH' , 'DELETE' , 'PUT' , 'OPTIONS' , 'REPORT' ] ) ) { $ temp [ 'method' ] = $ arg ; } else { $ temp [ 'url' ] = $ arg ; } } list ( $ method , $ url , $ handler ) = array_values ( $ temp ) ; if ( ! $ url && $ this -> prefix ) { $ url = $ this -> prefix ; } else { if ( ! $ url ) { $ url = '{**}' ; } $ url = $ this -> prefix . $ url ; } if ( ! $ method ) { $ method = [ 'GET' , 'POST' ] ; } if ( ! is_array ( $ method ) ) { $ method = [ $ method ] ; } if ( ! is_callable ( $ handler ) ) { throw new RouterException ( 'No valid handler found' ) ; } foreach ( $ method as $ m ) { if ( ! isset ( $ this -> routes [ $ m ] ) ) { $ this -> routes [ $ m ] = [ ] ; } $ this -> routes [ $ m ] [ $ url ] = $ handler ; } return $ this ; }
docstring: Add a route. All params are optional and each of them can be omitted independently.
  @param  array|string $method  HTTP verbs for which this route is valid
  @param  string       $url     the route URL (check the usage docs for information on supported formats)
  @param  callable     $handler the handler to execute when the route is matched
  @return self
docstring_tokens: Add a route . All params are optional and each of them can be omitted independently .