picea/src/ControlStructure/TryCatchToken.php
2025-10-15 14:57:42 +00:00

26 lines
671 B
PHP

<?php
namespace Picea\ControlStructure;
class TryCatchToken implements ControlStructure {
public array $token = [ "try", "catch", "finally", "endtry", "/try" ];
public function parse(\Picea\Compiler\Context &$context, ?string $arguments, string $token, array $options = []) : string {
switch($token) {
case "try":
return "<?php try { ?>";
case "catch":
return "<?php } catch($arguments) { ?>";
case "finally":
return "<?php } finally { ?>";
case "endtry":
case "/try":
return "<?php } ?>";
}
}
}