| 1 |
<?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 |
|
| 13 |
namespace Twig\Node\Expression; |
| 14 |
|
| 15 |
use Twig\Compiler; |
| 16 |
|
| 17 |
class 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 |
} |
| 37 |
|