API Documentation

PostAuthor
in package
implements Stringable

Object representation of a post author for the site.

Table of Contents

Interfaces

Stringable

Properties

$name  : string
The display name of the author.
$username  : string
The username of the author.
$website  : string|null
The author's website URL.

Methods

__construct()  : mixed
Construct a new Post Author object.
__toString()  : string
all()  : Collection<string, PostAuthor>
get()  : static
Get an Author from the config, or create it.
getName()  : string
getOrCreate()  : static
Dynamically get or create an author based on a username string or front matter array.
findUsername()  : string

Properties

$name read-only

The display name of the author.

public string $name

$username read-only

The username of the author.

public string $username

This is the key used to find authors in the config.

$website read-only

The author's website URL.

public string|null $website

Could for example, be a Twitter page, website, or a hyperlink to more posts by the author. Should be a fully qualified link, meaning it starts with http:// or https://.

Methods

__construct()

Construct a new Post Author object.

public __construct(string $username[, string|null $name = null ][, string|null $website = null ]) : mixed

If your input is in the form of an array, you may rather want to use the getOrCreate method.

Parameters
$username : string
$name : string|null = null
$website : string|null = null

__toString()

public __toString() : string
Return values
string

get()

Get an Author from the config, or create it.

public static get(string $username) : static
Parameters
$username : string
Return values
static

getName()

public getName() : string

This is not needed as the name property can be accessed directly.

Attributes
#[Deprecated]
$reason: 'Use the name property instead.'
$replacement: '%class%->name'
Return values
string

getOrCreate()

Dynamically get or create an author based on a username string or front matter array.

public static getOrCreate(string|array{username?: string, name?: string, website?: string} $data) : static
Parameters
$data : string|array{username?: string, name?: string, website?: string}
Return values
static

findUsername()

protected static findUsername(array{username?: string, name?: string, website?: string} $data) : string
Parameters
$data : array{username?: string, name?: string, website?: string}
Return values
string

        
On this page

Search results