Generates LICENSE files from composer.json metadata.
Description
This class orchestrates the license generation workflow:
- Reads metadata from composer.json via Reader
- Resolves the license identifier to a template filename
- Uses the central Template Engine and VariablesFactory to map out the substitutions
- 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.
Interfaces
Properties
Methods
Creates a new Generator instance.
Generates a LICENSE file at the specified path.
Generates license content without writing it to disk.
private
ClockInterface
$clock
private
ComposerJsonInterface
$composer
private
FilesystemInterface
$filesystem
private
Environment
$renderer
private
ResolverInterface
$resolver
Creates a new Generator instance.
public
__construct(ResolverInterface
$resolver, ComposerJsonInterface
$composer, ClockInterface
$clock, Environment
$renderer, FilesystemInterface
$filesystem) : mixed
Parameters
Description
The resolver for mapping license identifiers to templates
$clock
:
ClockInterface
$renderer
:
Environment
Description
The filesystem component for file operations
Generates a LICENSE file at the specified path.
public
generate(
string
$targetPath) : string|null
Parameters
$targetPath
:
string
Description
The full path where the LICENSE file should be written
Return values
Description
The generated license content, or null if generation failed
Generates license content without writing it to disk.
public
generateContent() : string|null
Return values
Description
the generated license content, or null if generation failed