Lines
100.00%
12 / 12
Methods
100.00%
2 / 2
Classes
100.00%
1 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| fromSection | 100.00% | 11 / 11 | 100.00% | 1 / 1 | 1 | ||
| 10 | final readonly class CodegenConfig | |
| 11 | { | |
| 12 | /** | |
| 13 | * @param list<string> $include | |
| 14 | * @param list<string> $exclude | |
| 15 | */ | |
| 16 | public function __construct( | |
| 17 | public ClassNamespace $namespace, | |
| 18 | public ProjectDirectory $outputDir, | |
| 19 | public array $include, | |
| 20 | public array $exclude, | |
| 21 | public DomainAttributesConfigCollection $attributes, | |
| 22 | ) {} | |
| 23 | ||
| 24 | /** @throws ConfigurationException */ | |
| 25 | public static function fromSection(ConfigSection $codegen, GeneratedNamespaceResolver $namespaces): self | |
| 26 | { | |
| 27 | $outputDir = $codegen->readParsedValue('output_dir', static fn(string $directory): ProjectDirectory => new ProjectDirectory($directory)); | |
| 28 | ||
| 29 | return new self( | |
| 30 | namespace: $codegen->findParsedValue('namespace', static fn(string $namespace): ClassNamespace => new ClassNamespace($namespace)) | |
| 31 | ?? $namespaces->resolveNamespaceFor($outputDir), | |
| 32 | outputDir: $outputDir, | |
| 33 | include: $codegen->readStringList('include'), | |
| 34 | exclude: $codegen->readStringList('exclude'), | |
| 35 | attributes: DomainAttributesConfigCollection::keyedByDomain( | |
| 36 | $codegen->readSection('attributes')->mapSubsections(DomainAttributesConfig::fromSection(...)), | |
| 37 | ), | |
| 38 | ); | |
| 39 | } | |
| 40 | } |