Generator   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 94
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 9
eloc 21
dl 0
loc 94
ccs 31
cts 31
cp 1
rs 10
c 1
b 0
f 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
A setTemplate() 0 3 1
A make() 0 5 1
A __construct() 0 5 1
A getTemplate() 0 3 1
A getAbsolutePath() 0 3 1
A setFs() 0 3 1
A setAbsolutePath() 0 3 1
A getFs() 0 3 1
A getCompiledTemplate() 0 8 1
1
<?php
2
3
/**
4
 * @copyright Bluz PHP Team
5
 * @link https://github.com/bluzphp/bluzman
6
 */
7
8
namespace Bluzman\Generator;
9
10
use Bluz\View\View;
0 ignored issues
show
Bug introduced by
The type Bluz\View\View was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use Bluzman\Generator\Template\AbstractTemplate;
12
use Symfony\Component\Filesystem\Filesystem;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Filesystem\Filesystem was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
14
/**
15
 * Generator
16
 *
17
 * @package  Bluzman\Generator
18
 *
19
 * @author   Pavel Machekhin
20
 * @created  2013-03-28 16:24
21
 */
22
class Generator
23
{
24
    /**
25
     * @var AbstractTemplate
26
     */
27
    protected $template;
28
29
    /**
30
     * @var string
31
     */
32
    protected $absolutePath;
33
34
    /**
35
     * @var Filesystem
36
     */
37
    protected $fs;
38 7
39
    public function __construct(AbstractTemplate $template)
40 7
    {
41 7
        $this->setTemplate($template);
42 7
        $this->setAbsolutePath(__DIR__);
43 7
        $this->setFs(new Filesystem());
44
    }
45
46
    /**
47
     * @return AbstractTemplate
48 7
     */
49
    public function getTemplate(): AbstractTemplate
50 7
    {
51
        return $this->template;
52
    }
53
54
    /**
55
     * @param AbstractTemplate $template
56 7
     */
57
    public function setTemplate(AbstractTemplate $template): void
58 7
    {
59 7
        $this->template = $template;
60
    }
61
62
    /**
63
     * @return string
64 6
     */
65
    public function getAbsolutePath(): string
66 6
    {
67
        return $this->absolutePath;
68
    }
69
70
    /**
71
     * @param string $absolutePath
72 7
     */
73
    public function setAbsolutePath(string $absolutePath): void
74 7
    {
75 7
        $this->absolutePath = $absolutePath;
76
    }
77
78
    /**
79
     * @return Filesystem
80 6
     */
81
    public function getFs(): Filesystem
82 6
    {
83
        return $this->fs;
84
    }
85
86
    /**
87
     * @param Filesystem $fs
88 7
     */
89
    public function setFs(Filesystem $fs): void
90 7
    {
91 7
        $this->fs = $fs;
92
    }
93
94
    /**
95
     * @internal param $path
96 6
     */
97
    public function make(): void
98 6
    {
99 6
        $this->getFs()->dumpFile(
100 6
            $this->getTemplate()->getFilePath(),
101
            $this->getCompiledTemplate()
102 6
        );
103
    }
104 6
105
    /**
106 6
     * @return string
107 6
     */
108 6
    public function getCompiledTemplate()
109 6
    {
110
        $view = new View();
111 6
        $view->setPath($this->getAbsolutePath());
112
        $view->setTemplate($this->getTemplate()->getTemplatePath());
113
        $view->setFromArray($this->getTemplate()->getTemplateData());
114
115
        return $view->render();
116
    }
117
}
118