TemplateFactory::getPath()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
/**
4
 * This file is part of slick/form package
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace Slick\Form\Renderer;
11
12
use Slick\Template\EngineInterface;
13
use Slick\Template\Template;
14
15
/**
16
 * Creates a Template engine for Form/Renderer
17
 *
18
 * @package Slick\Form\Renderer
19
 * @author  Filipe Silva <[email protected]>
20
 */
21
final class TemplateFactory
22
{
23
24
    /**
25
     * @var EngineInterface
26
     */
27
    private static $instance;
28
29
30
    /**
31
     * Gets the Slick/Form default engine renderer
32
     *
33
     * @return EngineInterface
34
     */
35 20
    public static function getEngine()
36
    {
37 20
        if (null === self::$instance) {
38 2
            Template::addPath(self::getPath());
39 2
            $template = new Template();
40 2
            self::$instance = $template->initialize();
41 2
        }
42 20
        return self::$instance;
43
    }
44
45
    /**
46
     * Returns the path where HTML templates will live in
47
     *
48
     * @return string
49
     */
50 2
    private static function getPath()
51
    {
52 2
        return dirname(dirname(__DIR__)).'/templates';
53
    }
54
}