Conditions | 7 |
Paths | 6 |
Total Lines | 21 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
14 | public function handle(array $match): string |
||
15 | { |
||
16 | static $count = 0; |
||
17 | |||
18 | if (!empty($match[5]) && empty($match[7])) { |
||
19 | throw new \Exception("Invalid tag"); // @codeCoverageIgnore |
||
20 | } |
||
21 | |||
22 | if (empty($match[5]) && !empty($match[7])) { |
||
23 | throw new \Exception("Invalid tag"); // @codeCoverageIgnore |
||
24 | } |
||
25 | |||
26 | $index = !empty($match[5]) && !empty($match[7]) |
||
27 | ? $match[7] |
||
28 | : 'index' . ++$count; |
||
29 | |||
30 | $replace = "<?php for (\$$index = 0; \$$index < $match[3]; \$$index++) { ?>"; |
||
31 | $replace .= $match[9]; |
||
32 | $replace .= "<?php } ?>"; |
||
33 | |||
34 | return $replace; |
||
35 | } |
||
37 |