Skip to content

PlaceholderResolver

github-actions edited this page Apr 10, 2026 · 2 revisions

Resolves placeholders in license templates with metadata values.

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.


Methods

resolve

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

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:

Parameter Type Description
$template string The license template content with placeholders
$metadata array{year?: int, organization?: string, author?: string, project?: string} The metadata values to use for replacement

Return Value:

The template with all resolved placeholders


Clone this wiki locally