ComposerFundingCodec

Class
Read only: Yes Final: Yes

Parses and renders Composer funding metadata.

Table of Contents

Methods

dump()

Applies a normalized funding profile to composer.json contents.

 : string
parse()

Parses Composer funding entries into a normalized funding profile.

 : FundingProfile
extractGithubSponsor()

Extracts a GitHub Sponsors handle from a funding URL.

 : string|null
insertFundingEntries()

Inserts funding entries in a stable Composer key order.

 : array<string, mixed>
Methods

dump()

Public

Applies a normalized funding profile to composer.json contents.

public dump( string  $contents, FundingProfile  $profile) : string
Parameters
$contents : string

Description

the composer.json contents

$profile : FundingProfile

Description

the merged funding profile

Return values
string

Description

the updated composer.json contents

parse()

Public

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

extractGithubSponsor()

Private

Extracts a GitHub Sponsors handle from a funding URL.

private extractGithubSponsor( string  $url) : string|null
Parameters
$url : string

Description

the funding URL

Return values
string|null

Description

the sponsor handle, or null when the URL is unsupported

insertFundingEntries()

Private

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
array<string, mixed>

Description

the composer payload with funding inserted