TemplateFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 34
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getEngine() 0 9 2
A getPath() 0 4 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
}