Yaffs site version 1.1
[yaffs-website] / vendor / symfony / expression-language / ExpressionFunction.php
1 <?php
2
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
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 namespace Symfony\Component\ExpressionLanguage;
13
14 /**
15  * Represents a function that can be used in an expression.
16  *
17  * A function is defined by two PHP callables. The callables are used
18  * by the language to compile and/or evaluate the function.
19  *
20  * The "compiler" function is used at compilation time and must return a
21  * PHP representation of the function call (it receives the function
22  * arguments as arguments).
23  *
24  * The "evaluator" function is used for expression evaluation and must return
25  * the value of the function call based on the values defined for the
26  * expression (it receives the values as a first argument and the function
27  * arguments as remaining arguments).
28  *
29  * @author Fabien Potencier <fabien@symfony.com>
30  */
31 class ExpressionFunction
32 {
33     private $name;
34     private $compiler;
35     private $evaluator;
36
37     /**
38      * Constructor.
39      *
40      * @param string   $name      The function name
41      * @param callable $compiler  A callable able to compile the function
42      * @param callable $evaluator A callable able to evaluate the function
43      */
44     public function __construct($name, $compiler, $evaluator)
45     {
46         $this->name = $name;
47         $this->compiler = $compiler;
48         $this->evaluator = $evaluator;
49     }
50
51     public function getName()
52     {
53         return $this->name;
54     }
55
56     public function getCompiler()
57     {
58         return $this->compiler;
59     }
60
61     public function getEvaluator()
62     {
63         return $this->evaluator;
64     }
65 }