MacroInlineVariableOutput   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 25
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A runVariableMacro() 0 21 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Ublaboo\Anabelle\Markdown\Macros;
6
7
final class MacroInlineVariableOutput extends AbstractMacroVariable implements IMacro
8
{
9
10
	protected function runVariableMacro(string & $content, int $depth): 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) use ($depth): string {
18
				$line = $this->docuScope->getInlineVariable($input[1]);
19
20
				if ($depth <= parent::MAX_EXECUTE_DEPTH) {
21
					foreach ($this->getMacrosToRunOnInlineVariables() as $macro) {
22
						$macro->runVariableMacro($line, $depth + 1);
23
					}
24
				}
25
26
				return $line;
27
			},
28
			$content
29
		);
30
	}
31
}
32