| Conditions | 6 |
| Paths | 5 |
| Total Lines | 35 |
| Code Lines | 26 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 43 | public function compile(Twig_Compiler $compiler) |
||
| 44 | { |
||
| 45 | $compiler->addDebugInfo($this); |
||
| 46 | |||
| 47 | $compiler |
||
| 48 | ->write('switch(') |
||
| 49 | ->subcompile($this->getNode('expression')) |
||
| 50 | ->raw(") {\n") |
||
| 51 | ->indent(); |
||
| 52 | |||
| 53 | $total = count($this->getNode('cases')); |
||
| 54 | for ($i = 0; $i < $total; $i++) { |
||
| 55 | $expr = $this->getNode('cases')->getNode($i)->getAttribute('expression'); |
||
| 56 | $body = $this->getNode('cases')->getNode($i)->getNode('body'); |
||
| 57 | if (is_null($expr)) { |
||
| 58 | $compiler |
||
| 59 | ->write('default') |
||
| 60 | ->raw(":\n"); |
||
| 61 | } else { |
||
| 62 | foreach ($expr as $subExpr) { |
||
| 63 | $compiler |
||
| 64 | ->write('case ') |
||
| 65 | ->subcompile($subExpr) |
||
| 66 | ->raw(":\n"); |
||
| 67 | } |
||
| 68 | } |
||
| 69 | $compiler->indent(); |
||
| 70 | $compiler->subcompile($body); |
||
| 71 | if ($i + 1 >= $total || !$this->getNode('cases')->getNode($i + 1)->getAttribute('fallthrough')) { |
||
| 72 | $compiler->write("break;\n"); |
||
| 73 | } |
||
| 74 | $compiler->outdent(); |
||
| 75 | } |
||
| 76 | |||
| 77 | $compiler->outdent()->write('}'); |
||
| 78 | } |
||
| 80 |