Method.php 748B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. /*
  3. * This file is part of Twig.
  4. *
  5. * (c) 2010 Fabien Potencier
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. /**
  11. * Represents a method template test.
  12. *
  13. * @package twig
  14. * @author Fabien Potencier <fabien@symfony.com>
  15. */
  16. class Twig_Test_Method implements Twig_TestInterface
  17. {
  18. protected $extension;
  19. protected $method;
  20. public function __construct(Twig_ExtensionInterface $extension, $method)
  21. {
  22. $this->extension = $extension;
  23. $this->method = $method;
  24. }
  25. public function compile()
  26. {
  27. return sprintf('$this->env->getExtension(\'%s\')->%s', $this->extension->getName(), $this->method);
  28. }
  29. }