Mustache::compiler()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
c 0
b 0
f 0
rs 9.4285
ccs 3
cts 3
cp 1
cc 2
eloc 3
nc 2
nop 0
crap 2
1
<?php 
2
3
namespace Helmut\Forms\Engines;
4
5
use Helmut\Forms\Engine;
6
use Mustache_Engine;
7
8
class Mustache implements Engine {
9
10
    /**
11
     * The mustache compiler engine.
12
     *
13
     * @var \Mustache_Engine
14
     */ 
15
    protected $compiler;
16
17
    /**
18
     * Fetch the compiler.
19
     *
20
     * @return \Mustache_Engine
21
     */
22 47
    public function compiler()
23
    {
24 47
        if ( ! $this->compiler) $this->compiler = new Mustache_Engine;
25
26 47
        return $this->compiler;
27
    }
28
29
    /**
30
     * Render the template content.
31
     *
32
     * @param  string  $path
33
     * @param  array  $properties
34
     * @return string
35
     */
36 47
    public function render($path, $properties = []) 
37
    {
38 47
        $content = file_get_contents($path);
39
40 47
        return $this->compiler()->render($content, $properties);
41
    }
42
43
}
44