4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\ExpressionLanguage\Node;
14 use Symfony\Component\ExpressionLanguage\Compiler;
17 * @author Fabien Potencier <fabien@symfony.com>
21 class ConditionalNode extends Node
23 public function __construct(Node $expr1, Node $expr2, Node $expr3)
26 array('expr1' => $expr1, 'expr2' => $expr2, 'expr3' => $expr3)
30 public function compile(Compiler $compiler)
34 ->compile($this->nodes['expr1'])
36 ->compile($this->nodes['expr2'])
38 ->compile($this->nodes['expr3'])
43 public function evaluate($functions, $values)
45 if ($this->nodes['expr1']->evaluate($functions, $values)) {
46 return $this->nodes['expr2']->evaluate($functions, $values);
49 return $this->nodes['expr3']->evaluate($functions, $values);