original_string: protected function addExtensionsFromTemplateConfiguration(
          Transformation $transformation,
          ProjectDescriptor $project,
          \Twig_Environment $twigEnvironment
      ) {
          $isDebug = $transformation->getParameter('twig-debug')
              ? $transformation->getParameter('twig-debug')->getValue()
              : false;
          if ($isDebug == 'true') {
              $twigEnvironment->enableDebug();
              $twigEnvironment->enableAutoReload();
              $twigEnvironment->addExtension(new \Twig_Extension_Debug());
          }
  
          /** @var Template\Parameter $extension */
          foreach ($transformation->getParametersWithKey('twig-extension') as $extension) {
              $extensionValue = $extension->getValue();
              if (!class_exists($extensionValue)) {
                  throw new \InvalidArgumentException('Unknown twig extension: ' . $extensionValue);
              }
  
              // to support 'normal' Twig extensions we check the interface to determine what instantiation to do.
              $implementsInterface = in_array(
                  'phpDocumentor\Plugin\Twig\ExtensionInterface',
                  class_implements($extensionValue)
              );
  
              $twigEnvironment->addExtension(
                  $implementsInterface ? new $extensionValue($project, $transformation) : new $extensionValue()
              );
          }
      }
code: protected function addExtensionsFromTemplateConfiguration(
          Transformation $transformation,
          ProjectDescriptor $project,
          \Twig_Environment $twigEnvironment
      ) {
          $isDebug = $transformation->getParameter('twig-debug')
              ? $transformation->getParameter('twig-debug')->getValue()
              : false;
          if ($isDebug == 'true') {
              $twigEnvironment->enableDebug();
              $twigEnvironment->enableAutoReload();
              $twigEnvironment->addExtension(new \Twig_Extension_Debug());
          }
  
          /** @var Template\Parameter $extension */
          foreach ($transformation->getParametersWithKey('twig-extension') as $extension) {
              $extensionValue = $extension->getValue();
              if (!class_exists($extensionValue)) {
                  throw new \InvalidArgumentException('Unknown twig extension: ' . $extensionValue);
              }
  
              // to support 'normal' Twig extensions we check the interface to determine what instantiation to do.
              $implementsInterface = in_array(
                  'phpDocumentor\Plugin\Twig\ExtensionInterface',
                  class_implements($extensionValue)
              );
  
              $twigEnvironment->addExtension(
                  $implementsInterface ? new $extensionValue($project, $transformation) : new $extensionValue()
              );
          }
      }
code_tokens: protected function addExtensionsFromTemplateConfiguration ( Transformation $ transformation , ProjectDescriptor $ project , \ Twig_Environment $ twigEnvironment ) { $ isDebug = $ transformation -> getParameter ( 'twig-debug' ) ? $ transformation -> getParameter ( 'twig-debug' ) -> getValue ( ) : false ; if ( $ isDebug == 'true' ) { $ twigEnvironment -> enableDebug ( ) ; $ twigEnvironment -> enableAutoReload ( ) ; $ twigEnvironment -> addExtension ( new \ Twig_Extension_Debug ( ) ) ; } /** @var Template\Parameter $extension */ foreach ( $ transformation -> getParametersWithKey ( 'twig-extension' ) as $ extension ) { $ extensionValue = $ extension -> getValue ( ) ; if ( ! class_exists ( $ extensionValue ) ) { throw new \ InvalidArgumentException ( 'Unknown twig extension: ' . $ extensionValue ) ; } // to support 'normal' Twig extensions we check the interface to determine what instantiation to do. $ implementsInterface = in_array ( 'phpDocumentor\Plugin\Twig\ExtensionInterface' , class_implements ( $ extensionValue ) ) ; $ twigEnvironment -> addExtension ( $ implementsInterface ? new $ extensionValue ( $ project , $ transformation ) : new $ extensionValue ( ) ) ; } }
docstring: Tries to add any custom extensions that have been defined in the template or the transformation's configuration.
  
  This method will read the `twig-extension` parameter of the transformation (which inherits the template's
  parameter set) and try to add those extensions to the environment.
  
  @param Transformation    $transformation
  @param ProjectDescriptor $project
  @param \Twig_Environment $twigEnvironment
  
  @throws \InvalidArgumentException if a twig-extension should be loaded but it could not be found.
  
  @return void
docstring_tokens: Tries to add any custom extensions that have been defined in the template or the transformation s configuration .