瀏覽代碼

Update Dirk.php

Add switch, case., default, break, endswitch.
Visman 2 年之前
父節點
當前提交
cc188cf437
共有 1 個文件被更改,包括 27 次插入0 次删除
  1. 27 0
      vendor/artoodetoo/dirk/src/Dirk.php

+ 27 - 0
vendor/artoodetoo/dirk/src/Dirk.php

@@ -499,4 +499,31 @@ class Dirk extends PhpEngine
     {
         return "<?php \$this->endBlock(true) ?>";
     }
+
+    protected function compileSwitch(string $expression): string
+    {
+        return "<?php switch {$expression}: ?>";
+    }
+
+    protected function compileCase(string $expression): string
+    {
+        $expression = \substr($expression, 1, -1);
+
+        return "<?php case {$expression}: ?>";
+    }
+
+    protected function compileDefault(): string
+    {
+        return "<?php default: ?>";
+    }
+
+    protected function compileEndswitch(): string
+    {
+        return "<?php endswitch ?>";
+    }
+
+    protected function compileBreak(): string
+    {
+        return "<?php break; ?>";
+    }
 }