Total Complexity | 3 |
Total Lines | 42 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
7 | class FactoryRegistryGenerator extends AbstractGenerator implements FactoryRegistryGeneratorInterface |
||
8 | { |
||
9 | protected const FILE_NAME = 'factory-registry'; |
||
10 | protected const TEMPLATE_NAME = 'factory-registry.twig'; |
||
11 | |||
12 | /** |
||
13 | * @param \Jellyfish\Transfer\Definition\ClassDefinitionInterface[] $classDefinitionMap |
||
14 | * |
||
15 | * @return \Jellyfish\Transfer\Generator\FactoryRegistryGeneratorInterface |
||
16 | * |
||
17 | * @throws \Twig\Error\LoaderError |
||
18 | * @throws \Twig\Error\RuntimeError |
||
19 | * @throws \Twig\Error\SyntaxError |
||
20 | */ |
||
21 | public function generate(array $classDefinitionMap): FactoryRegistryGeneratorInterface |
||
22 | { |
||
23 | $file = $this->getFile(); |
||
24 | $fileContent = $this->twig->render($this->getTemplateName(), [ |
||
25 | 'classDefinitionMap' => $classDefinitionMap |
||
26 | ]); |
||
27 | |||
28 | $this->createDirectories($this->targetDirectory); |
||
29 | |||
30 | $this->filesystem->writeToFile($this->targetDirectory . $file, $fileContent); |
||
31 | |||
32 | return $this; |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * @return string |
||
37 | */ |
||
38 | protected function getFile(): string |
||
39 | { |
||
40 | return static::FILE_NAME . static::FILE_EXTENSION; |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * @return string |
||
45 | */ |
||
46 | protected function getTemplateName(): string |
||
49 | } |
||
50 | } |
||
51 |