| Conditions | 3 |
| Paths | 3 |
| Total Lines | 19 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 24 | public function translate(Mailcode_Commands_Command_For $command): string |
||
| 25 | { |
||
| 26 | $loopBreak = ''; |
||
| 27 | if ($command->isBreakAtEnabled()) { |
||
| 28 | $token = $command->getBreakAtToken(); |
||
| 29 | if ($token !== null) { |
||
| 30 | $loopBreak = sprintf('#if($foreach.count > %s)#{break}#{end}', $token->getMatchedText()); |
||
| 31 | } |
||
| 32 | } |
||
| 33 | |||
| 34 | // Using $source.list() here to ensure that Velocity always treats |
||
| 35 | // the variable as a list, even if there is only a single entry |
||
| 36 | // in the list (it would otherwise iterate over the keys in the |
||
| 37 | // single entry). |
||
| 38 | return sprintf( |
||
| 39 | '#{foreach}(%s in %s.list())%s', |
||
| 40 | $command->getLoopVariable()->getFullName(), |
||
| 41 | $command->getSourceVariable()->getFullName(), |
||
| 42 | $loopBreak |
||
| 43 | ); |
||
| 46 |