Total Complexity | 3 |
Total Lines | 36 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php namespace Way\Generators; |
||
7 | class Generator |
||
8 | { |
||
9 | /** |
||
10 | * Run the generator |
||
11 | * |
||
12 | * @param string $templatePath |
||
13 | * @param array $templateData |
||
14 | * @param string $filePathToGenerate |
||
15 | * @throws FileExistsException |
||
16 | */ |
||
17 | public function make(string $templatePath, array $templateData, string $filePathToGenerate) |
||
18 | { |
||
19 | // We first need to compile the template, |
||
20 | // according to the data that we provide. |
||
21 | $template = $this->compile($templatePath, $templateData, new TemplateCompiler); |
||
22 | |||
23 | // Now that we have the compiled template, |
||
24 | // we can actually generate the file. |
||
25 | if (File::exists($filePathToGenerate)) { |
||
26 | throw new FileExistsException(); |
||
27 | } |
||
28 | |||
29 | File::put($filePathToGenerate, $template); |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * Compile the file |
||
34 | * |
||
35 | * @param string $templatePath |
||
36 | * @param array $data |
||
37 | * @param TemplateCompiler $compiler |
||
38 | * @return mixed |
||
39 | */ |
||
40 | public function compile(string $templatePath, array $data, TemplateCompiler $compiler) |
||
43 | } |
||
44 | } |
||
45 |