AssetMacroSet::install()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SixtyEightPublishers\Asset\Latte;
6
7
use Latte;
8
9 1
final class AssetMacroSet extends Latte\Macros\MacroSet
10
{
11
	/**
12
	 * @param \Latte\Compiler $compiler
13
	 *
14
	 * @return void
15
	 */
16 1
	public static function install(Latte\Compiler $compiler): void
17
	{
18 1
		$me = new static($compiler);
19
20 1
		$me->addMacro('asset', [$me, 'macroAsset']);
21 1
		$me->addMacro('asset_version', [$me, 'macroAssetVersion']);
22 1
	}
23
24
	/**
25
	 * @param \Latte\MacroNode $node
26
	 * @param \Latte\PhpWriter $writer
27
	 *
28
	 * @return string
29
	 * @throws \Latte\CompileException
30
	 */
31 1
	public function macroAsset(Latte\MacroNode $node, Latte\PhpWriter $writer): string
32
	{
33 1
		return $writer->write('echo %escape(%modify($this->global->symfonyPackages->getUrl(%node.args)))');
34
	}
35
36
	/**
37
	 * @param \Latte\MacroNode $node
38
	 * @param \Latte\PhpWriter $writer
39
	 *
40
	 * @return string
41
	 * @throws \Latte\CompileException
42
	 */
43 1
	public function macroAssetVersion(Latte\MacroNode $node, Latte\PhpWriter $writer): string
44
	{
45 1
		return $writer->write('echo %escape(%modify($this->global->symfonyPackages->getVersion(%node.args)))');
46
	}
47
}
48