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