GeneratorInterface

Interface

Generates LICENSE files from composer.json metadata.

Description

This interface defines the contract for generating license files by reading composer.json and producing appropriate license content.

Table of Contents

Methods

generate()

Generates a LICENSE file at the specified path.

 : string|null
hasLicense()

Checks whether a supported license is present in composer.json.

 : bool
Methods

generate()

Public

Generates a LICENSE file at the specified path.

public generate( string  $targetPath) : string|null

Description

Reads the license from composer.json, validates it's supported, loads the appropriate template, resolves placeholders, and writes the LICENSE file to the target path.

Parameters
$targetPath : string

Description

The full path where the LICENSE file should be written

Return values
string|null

Description

The generated license content, or null if generation failed

hasLicense()

Public

Checks whether a supported license is present in composer.json.

public hasLicense() : bool
Return values
bool

Description

True if a supported license is defined, false otherwise