CodeOwnersGenerator
Generates CODEOWNERS content from repository metadata.
Properties
Methods
Creates a new generator instance.
Generates CODEOWNERS contents.
Returns the repository or organization owner inferred from support metadata.
Returns the automatically inferred CODEOWNERS handles.
Normalizes user-provided owner tokens.
Extracts a GitHub user handle from a homepage URL.
Extracts the repository owner from a GitHub repository URL.
Returns the path portion of a GitHub URL when the host matches github.com.
private
ComposerJsonInterface
$composer
private
FileLocatorInterface
$fileLocator
private
FilesystemInterface
$filesystem
Creates a new generator instance.
public
__construct(ComposerJsonInterface
$composer, FilesystemInterface
$filesystem, FileLocatorInterface
$fileLocator) : mixed
Parameters
Description
the composer metadata accessor
Description
the filesystem used to read the packaged template
$fileLocator
:
FileLocatorInterface
Description
the locator used to find the packaged template
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
Description
the rendered CODEOWNERS file contents
Returns the repository or organization owner inferred from support metadata.
public
inferGroupOwner() : string|null
Return values
Description
the inferred group owner with @, or null when unavailable
Returns the automatically inferred CODEOWNERS handles.
public
inferOwners() : array<int, string>
Return values
Normalizes user-provided owner tokens.
public
normalizeOwners(
string
$owners) : array<int, string>
Parameters
$owners
:
string
Description
the raw owner input
Return values
Extracts a GitHub user handle from a homepage URL.
private
extractGitHubHandleFromUrl(
string
$url) : string|null
Parameters
$url
:
string
Description
the homepage URL
Return values
Description
the GitHub handle without @, or null when unavailable
Extracts the repository owner from a GitHub repository URL.
private
extractGitHubRepositoryOwner(
string
$url) : string|null
Parameters
$url
:
string
Description
the repository URL
Return values
Description
the owner without @, or null when unavailable
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
Description
the URL path, or null when the URL is not a GitHub URL