class Twitter extends GroupedTagBuilder
Methods
Get the builder key.
Determine whether no card properties or image are defined.
Get the dot-notated key this builder occupies in the Head::toArray() result.
Grouped tag builders are represented as an empty array when absent from the Head::toArray() result.
Get the supported route attribute names.
Build Twitter card metadata from a route attribute.
Determine if the builder should render even when no data was set.
Resolve a string or string-backed enum value.
Normalize a route attribute value into a list of items.
Create the Twitter card properties and image.
Create Twitter card metadata from named values.
Create Twitter card metadata from an attribute map.
Build a Twitter image from route values.
Get the Twitter card properties, falling back to the page title and description.
Get the card image or its Open Graph fallback.
Get nonempty Twitter card properties and the resolved image.
Set each specified Twitter card property.
Resolve a Twitter card type value.
Details
at line 34
static string
key()
Get the builder key.
at line 140
TagBuilder
overlayOn(TagBuilder|null $base)
Overlay these card properties and image onto the lower layer.
at line 155
bool
isEmpty()
Determine whether no card properties or image are defined.
in
TagBuilder at line 32
static string
headArrayKey()
Get the dot-notated key this builder occupies in the Head::toArray() result.
in
GroupedTagBuilder at line 13
static mixed
headArrayDefault()
Grouped tag builders are represented as an empty array when absent from the Head::toArray() result.
at line 44
static array
routeAttributeKeys()
Get the supported route attribute names.
at line 80
static TagBuilder|null
fromRouteAttribute(string $key, mixed $value)
Build Twitter card metadata from a route attribute.
in
TagBuilder at line 66
static bool
rendersWhenEmpty(ResolvedHead $head)
Determine if the builder should render even when no data was set.
in
TagBuilder at line 74
TagBuilder
asDefaults()
Mark the builder's data as belonging to the defaults layer.
at line 185
mixed
toHeadArray(ResolvedHead $head)
Get the resolved Twitter card metadata for the head array.
at line 195
array
toTags(ResolvedHead $head, TagRenderer $tags)
Render the Twitter card meta tags.
in
TagBuilder at line 100
static protected string|null
string(mixed $value)
Return the value when it is a string.
in
TagBuilder at line 108
static protected string|null
stringOrBackedEnum(mixed $value)
Resolve a string or string-backed enum value.
in
TagBuilder at line 124
static protected bool|null
bool(mixed $value)
Return the value when it is a boolean.
in
TagBuilder at line 132
static protected int|null
int(mixed $value)
Return the value when it is an integer.
in
TagBuilder at line 142
static protected array
items(mixed $value)
Normalize a route attribute value into a list of items.
in
TagBuilder at line 153
static protected array
named(array $values)
Filter an array down to its string-keyed values.
at line 25
__construct(array $properties = [], array|null $image = null)
Create the Twitter card properties and 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.
at line 94
static Twitter
fromAttributes(array $values)
Create Twitter card metadata from an attribute map.
at line 109
static Twitter
fromImageAttributes(mixed $image)
Build a Twitter image from route values.
at line 127
Twitter
image(string $url, string|null $alt = null)
Set the Twitter card image.
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.
at line 223
protected array|null
headArrayImage(array|null $fallback = null)
Get the card image or its Open Graph fallback.
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.
at line 247
protected void
set(array $properties)
Set each specified Twitter card property.
at line 259
static protected TwitterCard|string|null
twitterCard(mixed $value)
Resolve a Twitter card type value.