ComposerFundingCodec
Parses and renders Composer funding metadata.
Methods
Applies a normalized funding profile to composer.json contents.
Parses Composer funding entries into a normalized funding profile.
Extracts a GitHub Sponsors handle from a funding URL.
Inserts funding entries in a stable Composer key order.
Applies a normalized funding profile to composer.json contents.
public
dump(
string
$contents, FundingProfile
$profile) : string
Parameters
$contents
:
string
Description
the composer.json contents
Description
the merged funding profile
Return values
Description
the updated composer.json contents
Parses Composer funding entries into a normalized funding profile.
public
parse(
string
$contents) : FundingProfile
Parameters
$contents
:
string
Description
the composer.json contents
Return values
Description
the normalized funding profile
Extracts a GitHub Sponsors handle from a funding URL.
private
extractGithubSponsor(
string
$url) : string|null
Parameters
$url
:
string
Description
the funding URL
Return values
Description
the sponsor handle, or null when the URL is unsupported
Inserts funding entries in a stable Composer key order.
private
insertFundingEntries(
array<string, mixed>
$data,
array<int, array<string, mixed>>
$entries) : array<string, mixed>
Parameters
$data
:
array<string, mixed>
Description
the decoded composer.json payload
$entries
:
array<int, array<string, mixed>>
Description
the funding entries to insert
Return values
Description
the composer payload with funding inserted