Template   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 0
loc 67
ccs 0
cts 22
cp 0
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setEngine() 0 10 3
A getEngine() 0 4 1
A setLayout() 0 4 1
A setViewDir() 0 4 1
1
<?php
2
3
/**
4
 *
5
 * This file is part of the Apix Project.
6
 *
7
 * (c) Franck Cassedanne <franck at ouarz.net>
8
 *
9
 * @license     http://opensource.org/licenses/BSD-3-Clause  New BSD License
10
 *
11
 */
12
13
namespace Apix\View;
14
15
use Apix\View\Template as Template;
16
17
 class Template #implements Template\Adapter
18
{
19
20
    /**
21
     * Name of the templating engine.
22
     * @var  string
23
     */
24
    protected $engine = 'Apix\View\Template\Mustache';
25
26
    /**
27
     * The name of the template layout.
28
     * @var string
29
     */
30
    protected $layout = 'default';
31
32
    /**
33
     * The path to the view directory.
34
     * @var string
35
     */
36
    protected $view_dir = null;
37
38
    /**
39
     * Sets the engine name.
40
     *
41
     * @param string|null $engine
42
     */
43
    public function setEngine($engine = null)
44
    {
45
        $engine = null !== $engine ? $engine : $this->engine;
46
        if (!class_exists($engine)) {
47
            throw new \RuntimeException(
48
                sprintf('Template class "%s" does not exist.', $engine)
49
            );
50
        }
51
        $this->engine = $engine;
52
    }
53
54
    /**
55
     * Returns the engine name.
56
     *
57
     * @return string
58
     */
59
    public function getEngine()
60
    {
61
        return $this->engine;
62
    }
63
64
    /**
65
     * Sets the name of the template layout.
66
     *
67
     * @param string $layout
68
     */
69
    public function setLayout($layout)
70
    {
71
        $this->layout = $layout;
72
    }
73
74
    /**
75
     * Sets the main directory for this template view.
76
     * @var string
77
     */
78
    public function setViewDir($dir)
79
    {
80
        $this->view_dir = $dir;
81
    }
82
83
}
84