Skip to content

Generator

github-actions edited this page Apr 19, 2026 · 1 revision

Generates LICENSE files from composer.json metadata.

This class orchestrates the license generation workflow:

  1. Reads metadata from composer.json via Reader
  2. Resolves the license identifier to a template filename
  3. Uses the central Template Engine and VariablesFactory to map out the substitutions
  4. Writes the resulting LICENSE file to the target path

Generation is skipped if a LICENSE file already exists or if the license is not supported.


Methods

__construct

Creates a new Generator instance.

public __construct(\FastForward\DevTools\License\ResolverInterface $resolver, \FastForward\DevTools\Composer\Json\ComposerJsonInterface $composer, \Psr\Clock\ClockInterface $clock, \Twig\Environment $renderer, \FastForward\DevTools\Filesystem\FilesystemInterface $filesystem): mixed

Parameters:

Parameter Type Description
$resolver \FastForward\DevTools\License\ResolverInterface The resolver for mapping license identifiers to templates
$composer \FastForward\DevTools\Composer\Json\ComposerJsonInterface
$clock \Psr\Clock\ClockInterface
$renderer \Twig\Environment
$filesystem \FastForward\DevTools\Filesystem\FilesystemInterface The filesystem component for file operations

generate

Generates a LICENSE file at the specified path.

public generate(string $targetPath): string|null

Parameters:

Parameter Type Description
$targetPath string The full path where the LICENSE file should be written

Return Value:

The generated license content, or null if generation failed


generateContent

Generates license content without writing it to disk.

public generateContent(): string|null

Return Value:

the generated license content, or null if generation failed


Clone this wiki locally