class ComponentAttributeBag implements ArrayAccess, Htmlable, IteratorAggregate (View source)

Traits

Properties

static protected array $macros

The registered string macros.

from  Macroable
protected array $attributes

The raw array of attributes.

Methods

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

Apply the callback if the given "value" is truthy.

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

Apply the callback if the given "value" is falsy.

static void
macro(string $name, object|callable $macro)

Register a custom macro.

static void
mixin(object $mixin, bool $replace = true)

Mix another object into the class.

static bool
hasMacro(string $name)

Checks if macro is registered.

static void
flushMacros()

Flush the existing macros.

static mixed
__callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

mixed
__call(string $method, array $parameters)

Dynamically handle calls to the class.

void
__construct(array $attributes = [])

Create a new component attribute bag instance.

mixed
first(mixed $default = null)

Get the first attribute's value.

mixed
get(string $key, mixed $default = null)

Get a given attribute from the attribute array.

bool
has(string $key)

Determine if a given attribute exists in the attribute array.

only(mixed $keys)

Only include the given attribute from the attribute array.

except(mixed|array $keys)

Exclude the given attribute from the attribute array.

filter(callable $callback)

Filter the attributes, returning a bag of attributes that pass the filter.

whereStartsWith(string|string[] $needles)

Return a bag of attributes that have keys starting with the given value / pattern.

whereDoesntStartWith(string|string[] $needles)

Return a bag of attributes with keys that do not start with the given value / pattern.

thatStartWith(string|string[] $needles)

Return a bag of attributes that have keys starting with the given value / pattern.

exceptProps(mixed|array $keys)

Exclude the given attribute from the attribute array.

class(mixed|array $classList)

Conditionally merge classes into the attribute bag.

merge(array $attributeDefaults = [], bool $escape = true)

Merge additional attributes / values into the attribute bag.

bool
shouldEscapeAttributeValue(bool $escape, mixed $value)

Determine if the specific attribute value should be escaped.

prepends(mixed $value)

Create a new appendable attribute value.

mixed
resolveAppendableAttributeDefault(array $attributeDefaults, string $key, bool $escape)

Resolve an appendable attribute value default value.

array
getAttributes()

Get all of the raw attributes.

void
setAttributes(array $attributes)

Set the underlying attributes.

string
toHtml()

Get content as a string of HTML.

__invoke(array $attributeDefaults = [])

Merge additional attributes / values into the attribute bag.

bool
offsetExists(string $offset)

Determine if the given offset exists.

mixed
offsetGet(string $offset)

Get the value at the given offset.

void
offsetSet(string $offset, mixed $value)

Set the value at a given offset.

void
offsetUnset(string $offset)

Remove the value at the given offset.

getIterator()

Get an iterator for the items.

string
__toString()

Implode the attributes into a single HTML ready string.

Details

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

Apply the callback if the given "value" is truthy.

Parameters

mixed $value
callable $callback
callable|null $default

Return Value

$this|mixed

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

Apply the callback if the given "value" is falsy.

Parameters

mixed $value
callable $callback
callable|null $default

Return Value

$this|mixed

static void macro(string $name, object|callable $macro)

Register a custom macro.

Parameters

string $name
object|callable $macro

Return Value

void

static void mixin(object $mixin, bool $replace = true)

Mix another object into the class.

Parameters

object $mixin
bool $replace

Return Value

void

Exceptions

ReflectionException

static bool hasMacro(string $name)

Checks if macro is registered.

Parameters

string $name

Return Value

bool

static void flushMacros()

Flush the existing macros.

Return Value

void

static mixed __callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

mixed __call(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

void __construct(array $attributes = [])

Create a new component attribute bag instance.

Parameters

array $attributes

Return Value

void

mixed first(mixed $default = null)

Get the first attribute's value.

Parameters

mixed $default

Return Value

mixed

mixed get(string $key, mixed $default = null)

Get a given attribute from the attribute array.

Parameters

string $key
mixed $default

Return Value

mixed

bool has(string $key)

Determine if a given attribute exists in the attribute array.

Parameters

string $key

Return Value

bool

ComponentAttributeBag only(mixed $keys)

Only include the given attribute from the attribute array.

Parameters

mixed $keys

Return Value

ComponentAttributeBag

ComponentAttributeBag except(mixed|array $keys)

Exclude the given attribute from the attribute array.

Parameters

mixed|array $keys

Return Value

ComponentAttributeBag

ComponentAttributeBag filter(callable $callback)

Filter the attributes, returning a bag of attributes that pass the filter.

Parameters

callable $callback

Return Value

ComponentAttributeBag

ComponentAttributeBag whereStartsWith(string|string[] $needles)

Return a bag of attributes that have keys starting with the given value / pattern.

Parameters

string|string[] $needles

Return Value

ComponentAttributeBag

ComponentAttributeBag whereDoesntStartWith(string|string[] $needles)

Return a bag of attributes with keys that do not start with the given value / pattern.

Parameters

string|string[] $needles

Return Value

ComponentAttributeBag

ComponentAttributeBag thatStartWith(string|string[] $needles)

Return a bag of attributes that have keys starting with the given value / pattern.

Parameters

string|string[] $needles

Return Value

ComponentAttributeBag

ComponentAttributeBag exceptProps(mixed|array $keys)

Exclude the given attribute from the attribute array.

Parameters

mixed|array $keys

Return Value

ComponentAttributeBag

ComponentAttributeBag class(mixed|array $classList)

Conditionally merge classes into the attribute bag.

Parameters

mixed|array $classList

Return Value

ComponentAttributeBag

ComponentAttributeBag merge(array $attributeDefaults = [], bool $escape = true)

Merge additional attributes / values into the attribute bag.

Parameters

array $attributeDefaults
bool $escape

Return Value

ComponentAttributeBag

protected bool shouldEscapeAttributeValue(bool $escape, mixed $value)

Determine if the specific attribute value should be escaped.

Parameters

bool $escape
mixed $value

Return Value

bool

AppendableAttributeValue prepends(mixed $value)

Create a new appendable attribute value.

Parameters

mixed $value

Return Value

AppendableAttributeValue

protected mixed resolveAppendableAttributeDefault(array $attributeDefaults, string $key, bool $escape)

Resolve an appendable attribute value default value.

Parameters

array $attributeDefaults
string $key
bool $escape

Return Value

mixed

array getAttributes()

Get all of the raw attributes.

Return Value

array

void setAttributes(array $attributes)

Set the underlying attributes.

Parameters

array $attributes

Return Value

void

string toHtml()

Get content as a string of HTML.

Return Value

string

HtmlString __invoke(array $attributeDefaults = [])

Merge additional attributes / values into the attribute bag.

Parameters

array $attributeDefaults

Return Value

HtmlString

bool offsetExists(string $offset)

Determine if the given offset exists.

Parameters

string $offset

Return Value

bool

mixed offsetGet(string $offset)

Get the value at the given offset.

Parameters

string $offset

Return Value

mixed

void offsetSet(string $offset, mixed $value)

Set the value at a given offset.

Parameters

string $offset
mixed $value

Return Value

void

void offsetUnset(string $offset)

Remove the value at the given offset.

Parameters

string $offset

Return Value

void

ArrayIterator getIterator()

Get an iterator for the items.

Return Value

ArrayIterator

string __toString()

Implode the attributes into a single HTML ready string.

Return Value

string