original_string: public function middlewareGroup($name, array $middlewareNames)
      {
          if ($this->hasMiddleware($name)) {
              $message = "Cannot add middleware group '$name'. A middleware by this name has already been registered.";
              throw new RuntimeException($message);
          }
  
          foreach ($middlewareNames as $middlewareName) {
              if (!$this->hasMiddleware($middlewareName)) {
                  $message = "Cannot add '$middlewareName' middleware to group '$name'. It has not been registered.";
                  throw new RuntimeException($message);
              }
          }
  
          $this->_middlewareGroups[$name] = $middlewareNames;
  
          return $this;
      }
code: public function middlewareGroup($name, array $middlewareNames)
      {
          if ($this->hasMiddleware($name)) {
              $message = "Cannot add middleware group '$name'. A middleware by this name has already been registered.";
              throw new RuntimeException($message);
          }
  
          foreach ($middlewareNames as $middlewareName) {
              if (!$this->hasMiddleware($middlewareName)) {
                  $message = "Cannot add '$middlewareName' middleware to group '$name'. It has not been registered.";
                  throw new RuntimeException($message);
              }
          }
  
          $this->_middlewareGroups[$name] = $middlewareNames;
  
          return $this;
      }
code_tokens: public function middlewareGroup ( $ name , array $ middlewareNames ) { if ( $ this -> hasMiddleware ( $ name ) ) { $ message = "Cannot add middleware group '$name'. A middleware by this name has already been registered." ; throw new RuntimeException ( $ message ) ; } foreach ( $ middlewareNames as $ middlewareName ) { if ( ! $ this -> hasMiddleware ( $ middlewareName ) ) { $ message = "Cannot add '$middlewareName' middleware to group '$name'. It has not been registered." ; throw new RuntimeException ( $ message ) ; } } $ this -> _middlewareGroups [ $ name ] = $ middlewareNames ; return $ this ; }
docstring: Add middleware to a middleware group
  
  @param string $name Name of the middleware group
  @param array $middlewareNames Names of the middleware
  @return $this
docstring_tokens: Add middleware to a middleware group