public function __construct(Renderable $condition, $ifblock = NULL, $else = NULL) { parent::__construct($condition, $ifblock); if ($else) { $this->else = Utils::evalCallback($else); } }
public function testIfElseIfStatement() { $foo = new Variable('$foo'); $ifFoo = new IfStatement($foo, function () use($foo) { $block = new Block(); $block[] = new Statement(new AssignExpr($foo, new Constant(30))); return $block; }); $ifFoo->elif($foo, function () use($foo) { $block = new Block(); $block[] = new Statement(new AssignExpr($foo, new Constant(20))); return $block; }); $ifFoo->elif($foo, function () use($foo) { $block = new Block(); $block[] = new Statement(new AssignExpr($foo, new Constant(10))); return $block; }); $ifFoo->else(function () use($foo) { $block = new Block(); return $block; }); $this->assertCodeEqualsFile('tests/data/if_else_if_statement.fixture', $ifFoo); }
public function render(array $args = array()) { return ' else ' . parent::render($args); }