AttributesTrait
Attributes trait
Tags
Table of Contents
Properties
- $attributes : array<string|int, mixed>
- Attributes. An indexed list, not keyed by name — attributes can legitimately repeat (Attribute::IS_REPEATABLE), so a name-keyed map would silently collapse repeats.
Methods
- addAttribute() : static
- Add an attribute
- addAttributes() : static
- Add attributes
- getAttributes() : array<string|int, mixed>
- Get all attributes
- getAttributesByName() : array<string|int, mixed>
- Get all attributes with the given name (supports repeated attributes)
- hasAttribute() : bool
- Has an attribute with the given name
- hasAttributes() : bool
- Has attributes
- removeAttribute() : static
- Remove an attribute (by instance identity — there is no unique name to remove by)
- formatAttributes() : string
- Format the attributes
Properties
$attributes
Attributes. An indexed list, not keyed by name — attributes can legitimately repeat (Attribute::IS_REPEATABLE), so a name-keyed map would silently collapse repeats.
protected
array<string|int, mixed>
$attributes
= []
Methods
addAttribute()
Add an attribute
public
addAttribute(AttributeGenerator $attribute) : static
Parameters
- $attribute : AttributeGenerator
Return values
staticaddAttributes()
Add attributes
public
addAttributes(array<string|int, mixed> $attributes) : static
Parameters
- $attributes : array<string|int, mixed>
Return values
staticgetAttributes()
Get all attributes
public
getAttributes() : array<string|int, mixed>
Return values
array<string|int, mixed>getAttributesByName()
Get all attributes with the given name (supports repeated attributes)
public
getAttributesByName(string $name) : array<string|int, mixed>
Parameters
- $name : string
Return values
array<string|int, mixed>hasAttribute()
Has an attribute with the given name
public
hasAttribute(string $name) : bool
Parameters
- $name : string
Return values
boolhasAttributes()
Has attributes
public
hasAttributes() : bool
Return values
boolremoveAttribute()
Remove an attribute (by instance identity — there is no unique name to remove by)
public
removeAttribute(AttributeGenerator $attribute) : static
Parameters
- $attribute : AttributeGenerator
Return values
staticformatAttributes()
Format the attributes
protected
formatAttributes([bool $indented = true ]) : string
Parameters
- $indented : bool = true