AbstractTemplate   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 85
Duplicated Lines 0 %

Test Coverage

Coverage 85.71%

Importance

Changes 0
Metric Value
wmc 8
eloc 15
dl 0
loc 85
ccs 18
cts 21
cp 0.8571
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A setTemplatePath() 0 3 1
A getAuthor() 0 3 1
A getDefaultTemplateData() 0 7 1
A getTemplatePath() 0 3 1
A getFilePath() 0 3 1
A setTemplateData() 0 3 1
A getTemplateData() 0 3 1
A setFilePath() 0 3 1
1
<?php
2
3
/**
4
 * @copyright Bluz PHP Team
5
 * @link https://github.com/bluzphp/bluzman
6
 */
7
8
namespace Bluzman\Generator\Template;
9
10
/**
11
 * AbstractTemplate
12
 *
13
 * @package  Bluzman\Generator\Template
14
 *
15
 * @todo     Migrate to Bluz\View\View
16
 * @author   Pavel Machekhin
17
 * @created  2013-03-28 16:36
18
 */
19
abstract class AbstractTemplate
20
{
21
    /**
22
     * @var string
23
     */
24
    protected $templatePath;
25
26
    /**
27
     * @var array
28
     */
29
    protected $templateData = [];
30
31
    /**
32
     * @var string
33
     */
34
    protected $filePath;
35
36
    /**
37
     * @return string
38 6
     */
39
    public function getTemplatePath()
40 6
    {
41
        return $this->templatePath;
42
    }
43
44
    /**
45
     * @param string $templatePath
46
     */
47
    public function setTemplatePath(string $templatePath)
48
    {
49
        $this->templatePath = $templatePath;
50
    }
51
52
    /**
53
     * @return array
54 7
     */
55
    public function getTemplateData(): array
56 7
    {
57
        return array_merge($this->getDefaultTemplateData(), $this->templateData);
58
    }
59
60
    /**
61
     * @param array $templateData
62 6
     */
63
    public function setTemplateData(array $templateData)
64 6
    {
65 6
        $this->templateData = $templateData;
66
    }
67
68
    /**
69
     * @return string
70 6
     */
71
    public function getFilePath(): string
72 6
    {
73
        return $this->filePath;
74
    }
75
76
    /**
77
     * @param string $filePath
78 6
     */
79
    public function setFilePath(string $filePath)
80 6
    {
81 6
        $this->filePath = $filePath;
82
    }
83
84
    /**
85
     * Get the name of current user
86
     *
87
     * @return string
88 1
     */
89
    public function getAuthor(): string
90 1
    {
91
        return get_current_user();
92
    }
93
94
    /**
95
     * @return array
96 1
     */
97
    public function getDefaultTemplateData(): array
98 1
    {
99
        $date = new \DateTime();
100
101 1
        return [
102 1
            'author' => $this->getAuthor(),
103
            'date' => $date->format('Y-m-d H:i:s')
104
        ];
105
    }
106
}
107