blob: 2c7bd0a276cee290146ff37a1903277df689ee70 [file] [log] [blame]
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +01001<?php
2
3/*
4 * This file is part of Twig.
5 *
6 * (c) Fabien Potencier
7 * (c) Armin Ronacher
8 *
9 * For the full copyright and license information, please view the LICENSE
10 * file that was distributed with this source code.
11 */
12
13namespace Twig\Node\Expression;
14
15use Twig\Compiler;
16
17class ConditionalExpression extends AbstractExpression
18{
19 public function __construct(AbstractExpression $expr1, AbstractExpression $expr2, AbstractExpression $expr3, int $lineno)
20 {
21 parent::__construct(['expr1' => $expr1, 'expr2' => $expr2, 'expr3' => $expr3], [], $lineno);
22 }
23
24 public function compile(Compiler $compiler): void
25 {
26 $compiler
27 ->raw('((')
28 ->subcompile($this->getNode('expr1'))
29 ->raw(') ? (')
30 ->subcompile($this->getNode('expr2'))
31 ->raw(') : (')
32 ->subcompile($this->getNode('expr3'))
33 ->raw('))')
34 ;
35 }
36}