original_string: public function getRenderer($name)
      {
          // default
          if ($name === null) {
              if ($this->defaultRenderer !== null) {
                  $name = $this->defaultRenderer;
              } else if (count($this->renderers) > 0) {
                  $name = key($this->renderers);
              }
          }
  
          if (!isset($this->renderers[$name])) {
              throw new InvalidArgumentException("Renderer with name '$name' doesn't exist.");
          }
  
          if (is_string($this->renderers[$name])) {
              $renderer = new $this->renderers[$name]();
              $reflection = ClassType::from($renderer);
              if (!$reflection->isSubclassOf('Smf\Menu\Renderer\IRenderer')) {
                  throw new InvalidArgumentException("Renderer class '{$this->renderers[$name]}' is not subclass of Smf\\Menu\\Renderer\\IRenderer");
              }
              $this->renderers[$name] = $renderer;
          }
  
          return $this->renderers[$name];
      }
code: public function getRenderer($name)
      {
          // default
          if ($name === null) {
              if ($this->defaultRenderer !== null) {
                  $name = $this->defaultRenderer;
              } else if (count($this->renderers) > 0) {
                  $name = key($this->renderers);
              }
          }
  
          if (!isset($this->renderers[$name])) {
              throw new InvalidArgumentException("Renderer with name '$name' doesn't exist.");
          }
  
          if (is_string($this->renderers[$name])) {
              $renderer = new $this->renderers[$name]();
              $reflection = ClassType::from($renderer);
              if (!$reflection->isSubclassOf('Smf\Menu\Renderer\IRenderer')) {
                  throw new InvalidArgumentException("Renderer class '{$this->renderers[$name]}' is not subclass of Smf\\Menu\\Renderer\\IRenderer");
              }
              $this->renderers[$name] = $renderer;
          }
  
          return $this->renderers[$name];
      }
code_tokens: public function getRenderer ( $ name ) { // default if ( $ name === null ) { if ( $ this -> defaultRenderer !== null ) { $ name = $ this -> defaultRenderer ; } else if ( count ( $ this -> renderers ) > 0 ) { $ name = key ( $ this -> renderers ) ; } } if ( ! isset ( $ this -> renderers [ $ name ] ) ) { throw new InvalidArgumentException ( "Renderer with name '$name' doesn't exist." ) ; } if ( is_string ( $ this -> renderers [ $ name ] ) ) { $ renderer = new $ this -> renderers [ $ name ] ( ) ; $ reflection = ClassType :: from ( $ renderer ) ; if ( ! $ reflection -> isSubclassOf ( 'Smf\Menu\Renderer\IRenderer' ) ) { throw new InvalidArgumentException ( "Renderer class '{$this->renderers[$name]}' is not subclass of Smf\\Menu\\Renderer\\IRenderer" ) ; } $ this -> renderers [ $ name ] = $ renderer ; } return $ this -> renderers [ $ name ] ; }
docstring: Returns instance of the renderer
  
  @param  string            $name Name of the renderer
  @return IRenderer Renderer instance
  
  @throws InvalidArgumentException If the renderer with given name does not exist
docstring_tokens: Returns instance of the renderer