class HeadBuilder implements Transient

Traits

Methods

headData()

Get the head data instance the fluent methods should write to.

schemaFactory()

Get the schema factory used to resolve schema callbacks.

title(string $title, string|null $prefix = null, string|null $suffix = null, bool|null $exact = null)

Use $exact to render the title without inherited prefix or suffix.

description(string $description)

Set the page description.

themeColor(string $color, Media|string|null $media = null)

Set the theme color for the given media.

applicationName(string $name)

Set the application name.

colorScheme(string $scheme)

Set the supported color schemes.

referrer(string $policy)

Set the referrer policy.

viewport(string $content)

Set the viewport metadata.

appleWebAppTitle(string $title)

Set the Apple web app title.

webAppCapable(bool $capable = true)

Set whether the page supports web app mode.

appleWebAppStatusBarStyle(string $style)

Set the Apple web app status bar style.

canonical(string|null $url = null, bool|null $forceHttps = null, bool|null $trailingSlash = null)

Set the canonical URL and its normalization options.

robots(string|RobotsRule|array $directives)

Set the robots directives.

searchableByRobots()

Add a robots meta tag with the "all" directive, allowing search engines to index the page.

hiddenFromRobots()

Add a robots meta tag with the "none" directive, preventing search engines from indexing the page.

og(OgType|string|null $type = null, string|null $title = null, string|null $description = null, string|null $url = null, string|null $image = null, string|null $video = null, string|null $audio = null, string|null $siteName = null, string|null $locale = null, string|null $determiner = null)

Set Open Graph metadata.

ogImage(string $url, string|null $alt = null, int|null $width = null, int|null $height = null, ImageType|string|null $type = null, string|null $secureUrl = null)

Add an Open Graph image.

ogVideo(string $url, string|null $alt = null, int|null $width = null, int|null $height = null, string|null $type = null, string|null $secureUrl = null)

Add an Open Graph video.

ogAudio(string $url, string|null $type = null, string|null $secureUrl = null)

Add Open Graph audio.

twitter(TwitterCard|string|null $card = null, string|null $site = null, string|null $creator = null, string|null $title = null, string|null $description = null, string|null $image = null)

Set Twitter card metadata.

twitterImage(string $url, string|null $alt = null)

Set the Twitter card image.

preload(string $href, string|null $as = null, bool|string|null $crossorigin = null, ImageType|string|null $type = null, Media|string|null $media = null)

Add a resource preload hint.

preloadAsset(string $path, string|null $as = null, bool|string|null $crossorigin = null, ImageType|string|null $type = null, Media|string|null $media = null)

Add an asset preload hint.

prefetch(string $href, string|null $as = null)

Add a resource prefetch hint.

prefetchAsset(string $path, string|null $as = null)

Add an asset prefetch hint.

preconnect(string $href, bool|string|null $crossorigin = null)

Add a connection hint for an origin.

dnsPrefetch(string $href)

Add a DNS prefetch hint.

paginate(Paginator|CursorPaginator $paginator)

Add rel=prev/next links from a paginator instance.

alternates(array $alternates)

Add localized alternate URLs.

feed(string $href, string $title, string $type = 'rss')

Add a feed link.

schema(SchemaObject|array|callable $schema)

Add a JSON-LD schema object to the page.

meta(string $key, string $content, bool|null $property = null, Media|string|null $media = null)

Add a named or property-based meta tag.

link(string $rel, string $href, array $attributes = [])

Add a link with optional attributes.

icon(string $href, ImageType|string|null $type = null, string|null $sizes = null, Media|string|null $media = null)

Add an icon candidate.

favicon(string $href, ImageType|string|null $type = null, string|null $sizes = null, Media|string|null $media = null)

Add a favicon candidate.

appleTouchIcon(string $href, string|null $sizes = null)

Add an Apple touch icon.

maskIcon(string $href, string|null $color = null)

Add a pinned-tab mask icon.

manifest(string $href = '/site.webmanifest', bool|string|null $crossorigin = null)

Set the web app manifest link.

appleTouchStartupImage(string $href, Media|string|null $media = null)

Add an Apple startup image.

pwa(string $name, string $manifest = '/site.webmanifest', string|null $themeColor = null, string|null $appleTouchIcon = null, string|null $appleTouchIconSizes = '180x180', string|null $appleWebAppStatusBarStyle = null)

Set progressive web app metadata.

static array
linkAttributes(array $attributes)

Remove unspecified link attributes.

mixed
when(mixed $value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) truthy.

mixed
unless(mixed $value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) falsy.

__construct(HeadData $data, SchemaFactory|null $schemaFactory = null)

Create a builder for the given head data.

Details

at line 30
protected HeadData headData()

Get the head data instance the fluent methods should write to.

Return Value

HeadData

at line 38
protected SchemaFactory schemaFactory()

Get the schema factory used to resolve schema callbacks.

Return Value

SchemaFactory

in BuildsHead at line 47
BuildsHead title(string $title, string|null $prefix = null, string|null $suffix = null, bool|null $exact = null)

Use $exact to render the title without inherited prefix or suffix.

Parameters

string $title
string|null $prefix
string|null $suffix
bool|null $exact

Return Value

BuildsHead

in BuildsHead at line 57
BuildsHead description(string $description)

Set the page description.

Parameters

string $description

Return Value

BuildsHead

in BuildsHead at line 67
BuildsHead themeColor(string $color, Media|string|null $media = null)

Set the theme color for the given media.

Parameters

string $color
Media|string|null $media

Return Value

BuildsHead

in BuildsHead at line 75
BuildsHead applicationName(string $name)

Set the application name.

Parameters

string $name

Return Value

BuildsHead

in BuildsHead at line 83
BuildsHead colorScheme(string $scheme)

Set the supported color schemes.

Parameters

string $scheme

Return Value

BuildsHead

in BuildsHead at line 91
BuildsHead referrer(string $policy)

Set the referrer policy.

Parameters

string $policy

Return Value

BuildsHead

in BuildsHead at line 99
BuildsHead viewport(string $content)

Set the viewport metadata.

Parameters

string $content

Return Value

BuildsHead

in BuildsHead at line 107
BuildsHead appleWebAppTitle(string $title)

Set the Apple web app title.

Parameters

string $title

Return Value

BuildsHead

in BuildsHead at line 115
BuildsHead webAppCapable(bool $capable = true)

Set whether the page supports web app mode.

Parameters

bool $capable

Return Value

BuildsHead

in BuildsHead at line 123
BuildsHead appleWebAppStatusBarStyle(string $style)

Set the Apple web app status bar style.

Parameters

string $style

Return Value

BuildsHead

in BuildsHead at line 131
BuildsHead canonical(string|null $url = null, bool|null $forceHttps = null, bool|null $trailingSlash = null)

Set the canonical URL and its normalization options.

Parameters

string|null $url
bool|null $forceHttps
bool|null $trailingSlash

Return Value

BuildsHead

in BuildsHead at line 143
BuildsHead robots(string|RobotsRule|array $directives)

Set the robots directives.

Parameters

string|RobotsRule|array $directives

Return Value

BuildsHead

in BuildsHead at line 153
BuildsHead searchableByRobots()

Add a robots meta tag with the "all" directive, allowing search engines to index the page.

Return Value

BuildsHead

in BuildsHead at line 161
BuildsHead hiddenFromRobots()

Add a robots meta tag with the "none" directive, preventing search engines from indexing the page.

Return Value

BuildsHead

in BuildsHead at line 169
BuildsHead og(OgType|string|null $type = null, string|null $title = null, string|null $description = null, string|null $url = null, string|null $image = null, string|null $video = null, string|null $audio = null, string|null $siteName = null, string|null $locale = null, string|null $determiner = null)

Set Open Graph metadata.

Parameters

OgType|string|null $type
string|null $title
string|null $description
string|null $url
string|null $image
string|null $video
string|null $audio
string|null $siteName
string|null $locale
string|null $determiner

Return Value

BuildsHead

in BuildsHead at line 200
BuildsHead ogImage(string $url, string|null $alt = null, int|null $width = null, int|null $height = null, ImageType|string|null $type = null, string|null $secureUrl = null)

Add an Open Graph image.

Parameters

string $url
string|null $alt
int|null $width
int|null $height
ImageType|string|null $type
string|null $secureUrl

Return Value

BuildsHead

in BuildsHead at line 216
BuildsHead ogVideo(string $url, string|null $alt = null, int|null $width = null, int|null $height = null, string|null $type = null, string|null $secureUrl = null)

Add an Open Graph video.

Parameters

string $url
string|null $alt
int|null $width
int|null $height
string|null $type
string|null $secureUrl

Return Value

BuildsHead

in BuildsHead at line 232
BuildsHead ogAudio(string $url, string|null $type = null, string|null $secureUrl = null)

Add Open Graph audio.

Parameters

string $url
string|null $type
string|null $secureUrl

Return Value

BuildsHead

in BuildsHead at line 242
BuildsHead twitter(TwitterCard|string|null $card = null, string|null $site = null, string|null $creator = null, string|null $title = null, string|null $description = null, string|null $image = null)

Set Twitter card metadata.

Parameters

TwitterCard|string|null $card
string|null $site
string|null $creator
string|null $title
string|null $description
string|null $image

Return Value

BuildsHead

in BuildsHead at line 265
BuildsHead twitterImage(string $url, string|null $alt = null)

Set the Twitter card image.

Parameters

string $url
string|null $alt

Return Value

BuildsHead

in BuildsHead at line 275
BuildsHead preload(string $href, string|null $as = null, bool|string|null $crossorigin = null, ImageType|string|null $type = null, Media|string|null $media = null)

Add a resource preload hint.

Parameters

string $href
string|null $as
bool|string|null $crossorigin
ImageType|string|null $type
Media|string|null $media

Return Value

BuildsHead

in BuildsHead at line 285
BuildsHead preloadAsset(string $path, string|null $as = null, bool|string|null $crossorigin = null, ImageType|string|null $type = null, Media|string|null $media = null)

Add an asset preload hint.

Parameters

string $path
string|null $as
bool|string|null $crossorigin
ImageType|string|null $type
Media|string|null $media

Return Value

BuildsHead

in BuildsHead at line 295
BuildsHead prefetch(string $href, string|null $as = null)

Add a resource prefetch hint.

Parameters

string $href
string|null $as

Return Value

BuildsHead

in BuildsHead at line 305
BuildsHead prefetchAsset(string $path, string|null $as = null)

Add an asset prefetch hint.

Parameters

string $path
string|null $as

Return Value

BuildsHead

in BuildsHead at line 315
BuildsHead preconnect(string $href, bool|string|null $crossorigin = null)

Add a connection hint for an origin.

Parameters

string $href
bool|string|null $crossorigin

Return Value

BuildsHead

in BuildsHead at line 325
BuildsHead dnsPrefetch(string $href)

Add a DNS prefetch hint.

Parameters

string $href

Return Value

BuildsHead

in BuildsHead at line 337
BuildsHead paginate(Paginator|CursorPaginator $paginator)

Add rel=prev/next links from a paginator instance.

Parameters

Paginator|CursorPaginator $paginator

Return Value

BuildsHead

in BuildsHead at line 349
BuildsHead alternates(array $alternates)

Add localized alternate URLs.

Parameters

array $alternates

Return Value

BuildsHead

in BuildsHead at line 359
BuildsHead feed(string $href, string $title, string $type = 'rss')

Add a feed link.

Parameters

string $href
string $title
string $type

Return Value

BuildsHead

in BuildsHead at line 371
BuildsHead schema(SchemaObject|array|callable $schema)

Add a JSON-LD schema object to the page.

Parameters

SchemaObject|array|callable $schema

Return Value

BuildsHead

in BuildsHead at line 385
BuildsHead meta(string $key, string $content, bool|null $property = null, Media|string|null $media = null)

Add a named or property-based meta tag.

Parameters

string $key
string $content
bool|null $property
Media|string|null $media

Return Value

BuildsHead

Add a link with optional attributes.

Parameters

string $rel
string $href
array $attributes

Return Value

BuildsHead

in BuildsHead at line 407
BuildsHead icon(string $href, ImageType|string|null $type = null, string|null $sizes = null, Media|string|null $media = null)

Add an icon candidate.

Parameters

string $href
ImageType|string|null $type
string|null $sizes
Media|string|null $media

Return Value

BuildsHead

in BuildsHead at line 419
BuildsHead favicon(string $href, ImageType|string|null $type = null, string|null $sizes = null, Media|string|null $media = null)

Add a favicon candidate.

Parameters

string $href
ImageType|string|null $type
string|null $sizes
Media|string|null $media

Return Value

BuildsHead

in BuildsHead at line 427
BuildsHead appleTouchIcon(string $href, string|null $sizes = null)

Add an Apple touch icon.

Parameters

string $href
string|null $sizes

Return Value

BuildsHead

in BuildsHead at line 437
BuildsHead maskIcon(string $href, string|null $color = null)

Add a pinned-tab mask icon.

Parameters

string $href
string|null $color

Return Value

BuildsHead

in BuildsHead at line 447
BuildsHead manifest(string $href = '/site.webmanifest', bool|string|null $crossorigin = null)

Set the web app manifest link.

Parameters

string $href
bool|string|null $crossorigin

Return Value

BuildsHead

in BuildsHead at line 457
BuildsHead appleTouchStartupImage(string $href, Media|string|null $media = null)

Add an Apple startup image.

Parameters

string $href
Media|string|null $media

Return Value

BuildsHead

in BuildsHead at line 467
BuildsHead pwa(string $name, string $manifest = '/site.webmanifest', string|null $themeColor = null, string|null $appleTouchIcon = null, string|null $appleTouchIconSizes = '180x180', string|null $appleWebAppStatusBarStyle = null)

Set progressive web app metadata.

Parameters

string $name
string $manifest
string|null $themeColor
string|null $appleTouchIcon
string|null $appleTouchIconSizes
string|null $appleWebAppStatusBarStyle

Return Value

BuildsHead

in BuildsHead at line 501
static protected array linkAttributes(array $attributes)

Remove unspecified link attributes.

Parameters

array $attributes

Return Value

array

in Conditionable at line 23
mixed when(mixed $value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) truthy.

Parameters

mixed $value
callable|null $callback
callable|null $default

Return Value

mixed

in Conditionable at line 56
mixed unless(mixed $value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) falsy.

Parameters

mixed $value
callable|null $callback
callable|null $default

Return Value

mixed

at line 21
__construct(HeadData $data, SchemaFactory|null $schemaFactory = null)

Create a builder for the given head data.

Parameters

HeadData $data
SchemaFactory|null $schemaFactory