final class MetaData (View source)

Carries page-specific metadata independently from its HTML rendering.

Instances are immutable; modifier methods return a copy while preserving all other values.

Methods

__construct(string|null $websiteName = null, string|null $charset = null, string|null $viewport = null, string|null $rating = null, string|null $titleSeparator = null, string|null $title = null, string|null $description = null, string|null $keywords = null, string|null $author = null, string|null $robots = null, string|null $canonical = null, string|null $url = null, string|null $type = null, string|null $locale = null, string|null $image = null, string|null $imageAlt = null, array $custom = [], array $alternates = [])

Initializes page metadata and optional custom or alternate declarations.

withDefaults(string $websiteName, string $charset, string $viewport, string $rating, string $titleSeparator)

Returns a copy where empty standard values fall back to the supplied component defaults.

withTitleSeparator(string $separator)

Returns a copy with a title separator specific to this page.

string

Returns the page character encoding or an empty string when it is unset.

string
string

Returns the viewport declaration or an empty string when it is unset.

string
string

Returns the content rating or an empty string when it is unset.

string
string

Returns the website name or an empty string when it is unset.

string
string

Returns the title separator or an empty string when it is unset.

string
string

Returns the page title combined with the website name when a page title is present.

string
string|null

Returns the optional page description.

string|null
string|null

Returns the optional page keywords.

string|null
string|null

Returns the optional author attribution.

string|null
string|null

Returns the optional robots directive.

string|null
string|null

Returns the optional canonical URL.

string|null
string|null
getUrl()

Returns the optional page URL used by social metadata.

string|null
string|null

Returns the optional social metadata type.

string|null
string|null

Returns the optional locale used by social metadata.

string|null
string|null

Returns the optional image URL used by metadata sections.

string|null
string|null

Returns the optional alternative text for the metadata image.

string|null
array

Returns custom metadata keys and their optional values.

array
array

Returns alternate language codes mapped to their URLs.

array

Details

__construct

__construct(string|null $websiteName = null, string|null $charset = null, string|null $viewport = null, string|null $rating = null, string|null $titleSeparator = null, string|null $title = null, string|null $description = null, string|null $keywords = null, string|null $author = null, string|null $robots = null, string|null $canonical = null, string|null $url = null, string|null $type = null, string|null $locale = null, string|null $image = null, string|null $imageAlt = null, array $custom = [], array $alternates = [])

Initializes page metadata and optional custom or alternate declarations.

Parameters

string|null $websiteName
string|null $charset
string|null $viewport
string|null $rating
string|null $titleSeparator
string|null $title
string|null $description
string|null $keywords
string|null $author
string|null $robots
string|null $canonical
string|null $url
string|null $type
string|null $locale
string|null $image
string|null $imageAlt
array $custom
array $alternates

withDefaults

MetaData withDefaults(string $websiteName, string $charset, string $viewport, string $rating, string $titleSeparator)

Returns a copy where empty standard values fall back to the supplied component defaults.

Parameters

string $websiteName
string $charset
string $viewport
string $rating
string $titleSeparator

Return Value

MetaData

withTitleSeparator

MetaData withTitleSeparator(string $separator)

Returns a copy with a title separator specific to this page.

Parameters

string $separator

Return Value

MetaData

getCharset

string getCharset()

Returns the page character encoding or an empty string when it is unset.

Return Value

string

getViewport

string getViewport()

Returns the viewport declaration or an empty string when it is unset.

Return Value

string

getRating

string getRating()

Returns the content rating or an empty string when it is unset.

Return Value

string

getWebsiteName

string getWebsiteName()

Returns the website name or an empty string when it is unset.

Return Value

string

getTitleSeparator

string getTitleSeparator()

Returns the title separator or an empty string when it is unset.

Return Value

string

getTitle

string getTitle()

Returns the page title combined with the website name when a page title is present.

Return Value

string

getDescription

string|null getDescription()

Returns the optional page description.

Return Value

string|null

getKeywords

string|null getKeywords()

Returns the optional page keywords.

Return Value

string|null

getAuthor

string|null getAuthor()

Returns the optional author attribution.

Return Value

string|null

getRobots

string|null getRobots()

Returns the optional robots directive.

Return Value

string|null

getCanonical

string|null getCanonical()

Returns the optional canonical URL.

Return Value

string|null

getUrl

string|null getUrl()

Returns the optional page URL used by social metadata.

Return Value

string|null

getType

string|null getType()

Returns the optional social metadata type.

Return Value

string|null

getLocale

string|null getLocale()

Returns the optional locale used by social metadata.

Return Value

string|null

getImage

string|null getImage()

Returns the optional image URL used by metadata sections.

Return Value

string|null

getImageAlt

string|null getImageAlt()

Returns the optional alternative text for the metadata image.

Return Value

string|null

getCustom

array getCustom()

Returns custom metadata keys and their optional values.

Return Value

array

getAlternates

array getAlternates()

Returns alternate language codes mapped to their URLs.

Return Value

array