Completed
Pull Request — master (#4)
by James Ekow Abaka
03:06 queued 36s
created

MustacheEngine::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace ntentan\honam\engines;
4
5
use Mustache_Engine;
6
7
/**
8
 * Description of Mustache
9
 *
10
 * @author ekow
11
 */
12
class MustacheEngine extends AbstractEngine
13
{
14
    private $stringRenderingEngine;
15
    private $fileRenderingEngine;
16
17
    public function __construct(Mustache_Engine $stringRenderingEngine, Mustache_Engine $fileRenderingEngine)
18
    {
19
        $this->stringRenderingEngine = $stringRenderingEngine;
20
        $this->fileRenderingEngine = $fileRenderingEngine;
21
    }
22
23
    /**
24
     * Passes the data to be rendered to the template engine instance.
25
     * @param string $filePath
26
     * @param array $data
27
     * @return string
28
     */
29
    public function renderFromFileTemplate(string $filePath, array $data): string
30
    {
31
        return $this->fileRenderingEngine->render($filePath, $data);
32
    }
33
34
    /**
35
     * Passes a template string and data to be rendered to the template engine
36
     * instance.
37
     * @param string $string
38
     * @param array $data
39
     * @return string
40
     */
41
    public function renderFromStringTemplate(string $string, array $data): string
42
    {
43
        return $this->stringRenderingEngine->render($string, $data);
44
    }
45
}
46