Resolves placeholders in license templates with metadata values.
Description
This class replaces placeholders like {{ year }}, {{ author }}, {{ project }}, {{ organization }}, and {{ copyright_holder }} with values from metadata. Unresolved placeholders are removed and excess newlines are normalized.
Interfaces
Methods
resolve()
: string
Resolves placeholders in a license template with the provided metadata.
Resolves placeholders in a license template with the provided metadata.
public
resolve(
string
$template,
array{year?: int, organization?: string, author?: string, project?: string}
$metadata) : string
Description
Supported placeholders:
- {{ year }} - The copyright year (defaults to current year)
- {{ organization }} - The organization or vendor name
- {{ author }} - The primary author name or email
- {{ project }} - The project/package name
- {{ copyright_holder }} - Organization or author (organization takes precedence)
Unmatched placeholders are removed, and consecutive blank lines are normalized.
Parameters
$template
:
string
Description
The license template content with placeholders
$metadata
:
array{year?: int, organization?: string, author?: string, project?: string}
Description
The metadata values to use for replacement
Return values
string
Description
The template with all resolved placeholders