Author

Class
implements AuthorInterface
Read only: Yes Final: Yes

Concrete implementation of the ComposerJsonAuthorInterface.

Description

This class represents an author entry within a composer.json file and provides structured access to author metadata such as name, email, homepage, and role.

Implementations of this class MUST ensure that all provided data is consistent and valid according to Composer expectations. Consumers of this class MAY rely on its immutability if used in a readonly context.

The string representation of this class SHALL return a human-readable representation of the author.

Table of Contents

Interfaces

AuthorInterface

Defines the contract for representing an author entry within a composer.json file.

Properties

 : string
 : string
 : string
 : string

Methods

__construct()

Constructs a new ComposerJsonAuthor instance.

 : mixed
__toString()

Returns a string representation of the author.

 : string
getEmail()

Retrieves the email address of the author.

 : string
getHomepage()

Retrieves the homepage URL of the author.

 : string
getName()

Retrieves the name of the author.

 : string
getRole()

Retrieves the role of the author.

 : string
Properties

$email

Private
private string $email = ''

$homepage

Private
private string $homepage = ''

$name

Private
private string $name = ''

$role

Private
private string $role = ''
Methods

__construct()

Public

Constructs a new ComposerJsonAuthor instance.

public __construct([ string  $name = ''][, string  $email = ''][, string  $homepage = ''][, string  $role = '']) : mixed

Description

All parameters MUST be provided as strings. Implementations SHOULD validate the correctness of email and URL formats before assignment if strict validation is required.

Parameters
$name : string = ''

Description

the name of the author

$email : string = ''

Description

the email address of the author

$homepage : string = ''

Description

the homepage URL of the author

$role : string = ''

Description

the role of the author

__toString()

Public

Returns a string representation of the author.

public __toString() : string

Description

This method SHALL return a formatted string combining the author's name and email. Implementations MAY extend this format but SHOULD maintain readability.

Return values
string

Description

the string representation of the author

getEmail()

Public

Retrieves the email address of the author.

public getEmail() : string
Return values
string

Description

the email address of the author

getHomepage()

Public

Retrieves the homepage URL of the author.

public getHomepage() : string
Return values
string

Description

the homepage URL of the author

getName()

Public

Retrieves the name of the author.

public getName() : string
Return values
string

Description

the full name of the author

getRole()

Public

Retrieves the role of the author.

public getRole() : string
Return values
string

Description

the role of the author