Security update to Drupal 8.4.6
[yaffs-website] / vendor / twig / twig / lib / Twig / SimpleFilter.php
1 <?php
2
3 /*
4  * This file is part of Twig.
5  *
6  * (c) Fabien Potencier
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 /**
13  * Represents a template filter.
14  *
15  * @final
16  *
17  * @author Fabien Potencier <fabien@symfony.com>
18  */
19 class Twig_SimpleFilter
20 {
21     protected $name;
22     protected $callable;
23     protected $options;
24     protected $arguments = array();
25
26     public function __construct($name, $callable, array $options = array())
27     {
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);
42     }
43
44     public function getName()
45     {
46         return $this->name;
47     }
48
49     public function getCallable()
50     {
51         return $this->callable;
52     }
53
54     public function getNodeClass()
55     {
56         return $this->options['node_class'];
57     }
58
59     public function setArguments($arguments)
60     {
61         $this->arguments = $arguments;
62     }
63
64     public function getArguments()
65     {
66         return $this->arguments;
67     }
68
69     public function needsEnvironment()
70     {
71         return $this->options['needs_environment'];
72     }
73
74     public function needsContext()
75     {
76         return $this->options['needs_context'];
77     }
78
79     public function getSafe(Twig_Node $filterArgs)
80     {
81         if (null !== $this->options['is_safe']) {
82             return $this->options['is_safe'];
83         }
84
85         if (null !== $this->options['is_safe_callback']) {
86             return call_user_func($this->options['is_safe_callback'], $filterArgs);
87         }
88     }
89
90     public function getPreservesSafety()
91     {
92         return $this->options['preserves_safety'];
93     }
94
95     public function getPreEscape()
96     {
97         return $this->options['pre_escape'];
98     }
99
100     public function isVariadic()
101     {
102         return $this->options['is_variadic'];
103     }
104
105     public function isDeprecated()
106     {
107         return (bool) $this->options['deprecated'];
108     }
109
110     public function getDeprecatedVersion()
111     {
112         return $this->options['deprecated'];
113     }
114
115     public function getAlternative()
116     {
117         return $this->options['alternative'];
118     }
119 }
120
121 class_alias('Twig_SimpleFilter', 'Twig\TwigFilter', false);