CodeOwnersGenerator

Class
Read only: Yes Final: Yes

Generates CODEOWNERS content from repository metadata.

Table of Contents

Properties

Methods

__construct()

Creates a new generator instance.

 : mixed
generate()

Generates CODEOWNERS contents.

 : string
inferGroupOwner()

Returns the repository or organization owner inferred from support metadata.

 : string|null
inferOwners()

Returns the automatically inferred CODEOWNERS handles.

 : array<int, string>
normalizeOwners()

Normalizes user-provided owner tokens.

 : array<int, string>
extractGitHubHandleFromUrl()

Extracts a GitHub user handle from a homepage URL.

 : string|null
extractGitHubRepositoryOwner()

Extracts the repository owner from a GitHub repository URL.

 : string|null
githubPath()

Returns the path portion of a GitHub URL when the host matches github.com.

 : string|null
Properties
Methods

__construct()

Public

Creates a new generator instance.

public __construct(ComposerJsonInterface  $composer, FilesystemInterface  $filesystem, FileLocatorInterface  $fileLocator) : mixed
Parameters
$composer : ComposerJsonInterface

Description

the composer metadata accessor

$filesystem : FilesystemInterface

Description

the filesystem used to read the packaged template

$fileLocator : FileLocatorInterface

Description

the locator used to find the packaged template

generate()

Public

Generates CODEOWNERS contents.

public generate([ array<int, string>|null  $owners = null]) : string
Parameters
$owners : array<int, string>|null = null

Description

explicit owners to render; inferred owners are used when null

Return values
string

Description

the rendered CODEOWNERS file contents

inferGroupOwner()

Public

Returns the repository or organization owner inferred from support metadata.

public inferGroupOwner() : string|null
Return values
string|null

Description

the inferred group owner with @, or null when unavailable

inferOwners()

Public

Returns the automatically inferred CODEOWNERS handles.

public inferOwners() : array<int, string>
Return values
array<int, string>

normalizeOwners()

Public

Normalizes user-provided owner tokens.

public normalizeOwners( string  $owners) : array<int, string>
Parameters
$owners : string

Description

the raw owner input

Return values
array<int, string>

extractGitHubHandleFromUrl()

Private

Extracts a GitHub user handle from a homepage URL.

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

Description

the homepage URL

Return values
string|null

Description

the GitHub handle without @, or null when unavailable

extractGitHubRepositoryOwner()

Private

Extracts the repository owner from a GitHub repository URL.

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

Description

the repository URL

Return values
string|null

Description

the owner without @, or null when unavailable

githubPath()

Private

Returns the path portion of a GitHub URL when the host matches github.com.

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

Description

the URL to inspect

Return values
string|null

Description

the URL path, or null when the URL is not a GitHub URL