composer package updates
[openemr.git] / vendor / twig / twig / lib / Twig / SimpleFilter.php
blobee4c0aebf081f9b7433a3fa773268b9c7f9539ca
1 <?php
3 /*
4 * This file is part of Twig.
6 * (c) Fabien Potencier
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 /**
13 * Represents a template filter.
15 * @final
17 * @author Fabien Potencier <fabien@symfony.com>
19 class Twig_SimpleFilter
21 protected $name;
22 protected $callable;
23 protected $options;
24 protected $arguments = array();
26 public function __construct($name, $callable, array $options = array())
28 $this->name = $name;
29 $this->callable = $callable;
30 $this->options = array_merge(array(
31 'needs_environment' => false,
32 'needs_context' => false,
33 'is_variadic' => false,
34 'is_safe' => null,
35 'is_safe_callback' => null,
36 'pre_escape' => null,
37 'preserves_safety' => null,
38 'node_class' => 'Twig_Node_Expression_Filter',
39 'deprecated' => false,
40 'alternative' => null,
41 ), $options);
44 public function getName()
46 return $this->name;
49 public function getCallable()
51 return $this->callable;
54 public function getNodeClass()
56 return $this->options['node_class'];
59 public function setArguments($arguments)
61 $this->arguments = $arguments;
64 public function getArguments()
66 return $this->arguments;
69 public function needsEnvironment()
71 return $this->options['needs_environment'];
74 public function needsContext()
76 return $this->options['needs_context'];
79 public function getSafe(Twig_Node $filterArgs)
81 if (null !== $this->options['is_safe']) {
82 return $this->options['is_safe'];
85 if (null !== $this->options['is_safe_callback']) {
86 return call_user_func($this->options['is_safe_callback'], $filterArgs);
90 public function getPreservesSafety()
92 return $this->options['preserves_safety'];
95 public function getPreEscape()
97 return $this->options['pre_escape'];
100 public function isVariadic()
102 return $this->options['is_variadic'];
105 public function isDeprecated()
107 return (bool) $this->options['deprecated'];
110 public function getDeprecatedVersion()
112 return $this->options['deprecated'];
115 public function getAlternative()
117 return $this->options['alternative'];
121 class_alias('Twig_SimpleFilter', 'Twig\TwigFilter', false);