Completed
Push — master ( d9680d...b26789 )
by Pavel
09:43
created

MacroBlockVariable::runMacro()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 11

Duplication

Lines 19
Ratio 100 %

Importance

Changes 0
Metric Value
dl 19
loc 19
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 11
nc 1
nop 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Ublaboo\Anabelle\Markdown\Macros;
6
7 View Code Duplication
final class MacroBlockVariable extends AbstractMacroVariable implements IMacro
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
8
{
9
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]+)\n(.+)\$\$$/ms',
17
			function(array $input): string {
18
				$this->docuScope->addBlockVariable($input[1], $input[2]);
19
20
				return '';
21
			},
22
			$content
23
		);
24
	}
25
}
26