AssetMacroSet   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 6
c 1
b 0
f 0
dl 0
loc 37
ccs 10
cts 10
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A macroAssetVersion() 0 3 1
A install() 0 6 1
A macroAsset() 0 3 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