ComponentAttributeBag
Implements
Uses
Properties
$attributes array
The raw array of attributes.
Methods
__construct ( array $attributes ) : void
Create a new component attribute bag instance.
Parameters
- $attributes array
first ( $default ) : mixed
Get the first attribute's value.
Parameters
- $default mixed
get ( $key , $default ) : mixed
Get a given attribute from the attribute array.
Parameters
- $key string
- $default mixed
has ( $key ) : bool
Determine if a given attribute exists in the attribute array.
Parameters
- $key array|string
hasAny ( $key ) : bool
Determine if any of the keys exist in the attribute array.
Parameters
- $key array|string
missing ( $key ) : bool
Determine if a given attribute is missing from the attribute array.
Parameters
- $key string
only ( $keys ) : static
Only include the given attribute from the attribute array.
Parameters
- $keys mixed
except ( $keys ) : static
Exclude the given attribute from the attribute array.
Parameters
- $keys mixed|array
filter ( $callback ) : static
Filter the attributes, returning a bag of attributes that pass the filter.
Parameters
- $callback callable
whereStartsWith ( $needles ) : static
Return a bag of attributes that have keys starting with the given value / pattern.
Parameters
- $needles string|string[]
whereDoesntStartWith ( $needles ) : static
Return a bag of attributes with keys that do not start with the given value / pattern.
Parameters
- $needles string|string[]
thatStartWith ( $needles ) : static
Return a bag of attributes that have keys starting with the given value / pattern.
Parameters
- $needles string|string[]
onlyProps ( $keys ) : static
Only include the given attribute from the attribute array.
Parameters
- $keys mixed|array
exceptProps ( $keys ) : static
Exclude the given attribute from the attribute array.
Parameters
- $keys mixed|array
extractPropNames ( $keys ) : array
Extract prop names from given keys.
Parameters
- $keys mixed|array
class ( $classList ) : static
Conditionally merge classes into the attribute bag.
Parameters
- $classList mixed|array
style ( $styleList ) : static
Conditionally merge styles into the attribute bag.
Parameters
- $styleList mixed|array
merge ( array $attributeDefaults , $escape ) : static
Merge additional attributes / values into the attribute bag.
Parameters
- $attributeDefaults array
- $escape bool
shouldEscapeAttributeValue ( $escape , $value ) : bool
Determine if the specific attribute value should be escaped.
Parameters
- $escape bool
- $value mixed
prepends ( $value ) : AppendableAttributeValue
Create a new appendable attribute value.
Parameters
- $value mixed
resolveAppendableAttributeDefault ( $attributeDefaults , $key , $escape ) : mixed
Resolve an appendable attribute value default value.
Parameters
- $attributeDefaults array
- $key string
- $escape bool
getAttributes ( ) : array
Get all of the raw attributes.
setAttributes ( array $attributes ) : void
Set the underlying attributes.
Parameters
- $attributes array
toHtml ( ) : string
Get content as a string of HTML.
__invoke ( array $attributeDefaults ) : HtmlString
Merge additional attributes / values into the attribute bag.
Parameters
- $attributeDefaults array
offsetExists ( $offset ) : bool
Determine if the given offset exists.
Parameters
- $offset string
offsetGet ( $offset ) : mixed
Get the value at the given offset.
Parameters
- $offset string
offsetSet ( $offset , $value ) : void
Set the value at a given offset.
Parameters
- $offset string
- $value mixed
offsetUnset ( $offset ) : void
Remove the value at the given offset.
Parameters
- $offset string
__toString ( ) : string
Implode the attributes into a single HTML ready string.