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

MustacheEngine   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 32
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A renderFromStringTemplate() 0 3 1
A __construct() 0 4 1
A renderFromFileTemplate() 0 3 1
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