27 lines
660 B
PHP
27 lines
660 B
PHP
<?php
|
|
|
|
namespace Picea\ControlStructure;
|
|
|
|
class IfToken implements ControlStructure {
|
|
|
|
public array $token = [ "if", "else", "elseif", "endif", "/if" ];
|
|
|
|
public function parse(\Picea\Compiler\Context &$context, ?string $arguments, string $token, array $options = []) : string {
|
|
switch($token) {
|
|
case "if":
|
|
return "<?php if ($arguments): ?>";
|
|
|
|
case "else":
|
|
return "<?php else: ?>";
|
|
|
|
case "elseif":
|
|
return "<?php elseif ($arguments): ?>";
|
|
|
|
case "/if":
|
|
case "endif":
|
|
return "<?php endif ?>";
|
|
}
|
|
}
|
|
|
|
}
|