MetaData
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
Initializes page metadata and optional custom or alternate declarations.
Returns a copy where empty standard values fall back to the supplied component defaults.
Returns a copy with a title separator specific to this page.
Returns the page character encoding or an empty string when it is unset.
Returns the viewport declaration or an empty string when it is unset.
Returns the content rating or an empty string when it is unset.
Returns the website name or an empty string when it is unset.
Returns the title separator or an empty string when it is unset.
Returns the page title combined with the website name when a page title is present.
Returns the optional page description.
Returns the optional page keywords.
Returns the optional author attribution.
Returns the optional robots directive.
Returns the optional canonical URL.
Returns the optional page URL used by social metadata.
Returns the optional social metadata type.
Returns the optional locale used by social metadata.
Returns the optional image URL used by metadata sections.
Returns the optional alternative text for the metadata image.
Returns custom metadata keys and their optional values.
Returns alternate language codes mapped to their URLs.
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.
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.
withTitleSeparator
MetaData
withTitleSeparator(string $separator)
Returns a copy with a title separator specific to this page.
getCharset
string
getCharset()
Returns the page character encoding or an empty string when it is unset.
getViewport
string
getViewport()
Returns the viewport declaration or an empty string when it is unset.
getRating
string
getRating()
Returns the content rating or an empty string when it is unset.
getWebsiteName
string
getWebsiteName()
Returns the website name or an empty string when it is unset.
getTitleSeparator
string
getTitleSeparator()
Returns the title separator or an empty string when it is unset.
getTitle
string
getTitle()
Returns the page title combined with the website name when a page title is present.
getDescription
string|null
getDescription()
Returns the optional page description.
getKeywords
string|null
getKeywords()
Returns the optional page keywords.
getAuthor
string|null
getAuthor()
Returns the optional author attribution.
getRobots
string|null
getRobots()
Returns the optional robots directive.
getCanonical
string|null
getCanonical()
Returns the optional canonical URL.
getUrl
string|null
getUrl()
Returns the optional page URL used by social metadata.
getType
string|null
getType()
Returns the optional social metadata type.
getLocale
string|null
getLocale()
Returns the optional locale used by social metadata.
getImage
string|null
getImage()
Returns the optional image URL used by metadata sections.
getImageAlt
string|null
getImageAlt()
Returns the optional alternative text for the metadata image.
getCustom
array
getCustom()
Returns custom metadata keys and their optional values.
getAlternates
array
getAlternates()
Returns alternate language codes mapped to their URLs.