MustacheLoader   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 44
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getName() 0 4 1
A load() 0 5 1
1
<?php
2
3
/**
4
 * This file is part of file-fixture.
5
 *
6
 * (c) Noritaka Horio <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace holyshared\fixture\loader;
13
14
use holyshared\fixture\Loader;
15
use holyshared\fixture\FixtureLoader;
16
use Mustache_Engine;
17
18
19
final class MustacheLoader implements FixtureLoader
20
{
21
22
    const NAME = 'mustache';
23
24
    /**
25
     * @var \holyshared\fixture\Loader
26
     */
27
    private $loader;
28
29
    /**
30
     * @var \Mustache_Engine
31
     */
32
    private $mustache;
33
34
    /**
35
     * Create a new template loader of mustache
36
     *
37
     * @param \holyshared\fixture\Loader
38
     */
39
    public function __construct(Loader $loader)
40
    {
41
        $this->loader = $loader;
42
        $this->mustache = new Mustache_Engine();
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function getName()
49
    {
50
        return static::NAME;
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56
    public function load($path, array $arguments = [])
57
    {
58
        $template = $this->loader->load($path, $arguments);
59
        return $this->mustache->render($template, $arguments);
60
    }
61
62
}
63