class Twitter extends GroupedTagBuilder

Methods

static string
key()

Get the builder key.

overlayOn(TagBuilder|null $base)

Overlay these card properties and image onto the lower layer.

bool
isEmpty()

Determine whether no card properties or image are defined.

static string
headArrayKey()

Get the dot-notated key this builder occupies in the Head::toArray() result.

static mixed
headArrayDefault()

Grouped tag builders are represented as an empty array when absent from the Head::toArray() result.

static array
routeAttributeKeys()

Get the supported route attribute names.

static TagBuilder|null
fromRouteAttribute(string $key, mixed $value)

Build Twitter card metadata from a route attribute.

static bool
rendersWhenEmpty(ResolvedHead $head)

Determine if the builder should render even when no data was set.

asDefaults()

Mark the builder's data as belonging to the defaults layer.

mixed
toHeadArray(ResolvedHead $head)

Get the resolved Twitter card metadata for the head array.

array
toTags(ResolvedHead $head, TagRenderer $tags)

Render the Twitter card meta tags.

static string|null
string(mixed $value)

Return the value when it is a string.

static string|null
stringOrBackedEnum(mixed $value)

Resolve a string or string-backed enum value.

static bool|null
bool(mixed $value)

Return the value when it is a boolean.

static int|null
int(mixed $value)

Return the value when it is an integer.

static array
items(mixed $value)

Normalize a route attribute value into a list of items.

static array
named(array $values)

Filter an array down to its string-keyed values.

__construct(array $properties = [], array|null $image = null)

Create the Twitter card properties and image.

static Twitter
make(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)

Create Twitter card metadata from named values.

static Twitter
fromAttributes(array $values)

Create Twitter card metadata from an attribute map.

static Twitter
fromImageAttributes(mixed $image)

Build a Twitter image from route values.

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

Set the Twitter card image.

array
render(string|null $title = null, string|null $description = null)

Get the Twitter card properties, falling back to the page title and description.

array|null
headArrayImage(array|null $fallback = null)

Get the card image or its Open Graph fallback.

array
headArray(string|null $title = null, string|null $description = null, array|null $fallbackImage = null)

Get nonempty Twitter card properties and the resolved image.

void
set(array $properties)

Set each specified Twitter card property.

static TwitterCard|string|null
twitterCard(mixed $value)

Resolve a Twitter card type value.

Details

at line 34
static string key()

Get the builder key.

Return Value

string

at line 140
TagBuilder overlayOn(TagBuilder|null $base)

Overlay these card properties and image onto the lower layer.

Parameters

TagBuilder|null $base

Return Value

TagBuilder

at line 155
bool isEmpty()

Determine whether no card properties or image are defined.

Return Value

bool

in TagBuilder at line 32
static string headArrayKey()

Get the dot-notated key this builder occupies in the Head::toArray() result.

Return Value

string

in GroupedTagBuilder at line 13
static mixed headArrayDefault()

Grouped tag builders are represented as an empty array when absent from the Head::toArray() result.

Return Value

mixed

at line 44
static array routeAttributeKeys()

Get the supported route attribute names.

Return Value

array

at line 80
static TagBuilder|null fromRouteAttribute(string $key, mixed $value)

Build Twitter card metadata from a route attribute.

Parameters

string $key
mixed $value

Return Value

TagBuilder|null

in TagBuilder at line 66
static bool rendersWhenEmpty(ResolvedHead $head)

Determine if the builder should render even when no data was set.

Parameters

ResolvedHead $head

Return Value

bool

in TagBuilder at line 74
TagBuilder asDefaults()

Mark the builder's data as belonging to the defaults layer.

Return Value

TagBuilder

at line 185
mixed toHeadArray(ResolvedHead $head)

Get the resolved Twitter card metadata for the head array.

Parameters

ResolvedHead $head

Return Value

mixed

at line 195
array toTags(ResolvedHead $head, TagRenderer $tags)

Render the Twitter card meta tags.

Parameters

ResolvedHead $head
TagRenderer $tags

Return Value

array

in TagBuilder at line 100
static protected string|null string(mixed $value)

Return the value when it is a string.

Parameters

mixed $value

Return Value

string|null

in TagBuilder at line 108
static protected string|null stringOrBackedEnum(mixed $value)

Resolve a string or string-backed enum value.

Parameters

mixed $value

Return Value

string|null

in TagBuilder at line 124
static protected bool|null bool(mixed $value)

Return the value when it is a boolean.

Parameters

mixed $value

Return Value

bool|null

in TagBuilder at line 132
static protected int|null int(mixed $value)

Return the value when it is an integer.

Parameters

mixed $value

Return Value

int|null

in TagBuilder at line 142
static protected array items(mixed $value)

Normalize a route attribute value into a list of items.

Parameters

mixed $value

Return Value

array

in TagBuilder at line 153
static protected array named(array $values)

Filter an array down to its string-keyed values.

Parameters

array $values

Return Value

array

at line 25
__construct(array $properties = [], array|null $image = null)

Create the Twitter card properties and image.

Parameters

array $properties
array|null $image

at line 52
static Twitter make(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)

Create Twitter card metadata from named values.

Parameters

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

Return Value

Twitter

at line 94
static Twitter fromAttributes(array $values)

Create Twitter card metadata from an attribute map.

Parameters

array $values

Return Value

Twitter

at line 109
static Twitter fromImageAttributes(mixed $image)

Build a Twitter image from route values.

Parameters

mixed $image

Return Value

Twitter

at line 127
Twitter image(string $url, string|null $alt = null)

Set the Twitter card image.

Parameters

string $url
string|null $alt

Return Value

Twitter

at line 165
array render(string|null $title = null, string|null $description = null)

Get the Twitter card properties, falling back to the page title and description.

Parameters

string|null $title
string|null $description

Return Value

array

at line 223
protected array|null headArrayImage(array|null $fallback = null)

Get the card image or its Open Graph fallback.

Parameters

array|null $fallback

Return Value

array|null

at line 234
protected array headArray(string|null $title = null, string|null $description = null, array|null $fallbackImage = null)

Get nonempty Twitter card properties and the resolved image.

Parameters

string|null $title
string|null $description
array|null $fallbackImage

Return Value

array

at line 247
protected void set(array $properties)

Set each specified Twitter card property.

Parameters

array $properties

Return Value

void

at line 259
static protected TwitterCard|string|null twitterCard(mixed $value)

Resolve a Twitter card type value.

Parameters

mixed $value

Return Value

TwitterCard|string|null