| Conditions | 3 |
| Paths | 1 |
| Total Lines | 30 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | protected function runVariableMacro(string & $content): void // Intentionally & |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * Remove lines with inline variables definition and put then into DocuScope |
||
| 14 | */ |
||
| 15 | $content = preg_replace_callback( |
||
| 16 | '/(^.*)?\{\$\$([a-zA-Z_0-9]+)\}/m', |
||
| 17 | function(array $input): string { |
||
| 18 | $whitespacePrefix = ''; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * Prefix the whole block with current identation |
||
| 22 | */ |
||
| 23 | foreach (str_split($input[1]) as $character) { |
||
| 24 | if ($character === "\t") { |
||
| 25 | $whitespacePrefix .= $character; |
||
| 26 | |||
| 27 | continue; |
||
| 28 | } |
||
| 29 | |||
| 30 | break; |
||
| 31 | } |
||
| 32 | |||
| 33 | $block = $this->docuScope->getBlockVariable($input[2]); |
||
| 34 | |||
| 35 | return $input[1] . preg_replace('/\n/m', "\n{$whitespacePrefix}", $block); |
||
| 36 | }, |
||
| 37 | $content |
||
| 38 | ); |
||
| 39 | } |
||
| 40 | } |
||
| 41 |