trait HasAttributesTrait (View source)

Represent an object which has an array of attributes.

Methods

mixed
getAttribute(string $attribute, mixed $default = '')

Get attribute.

array
getAttributes()

Get all attributes.

void
setAttribute(string $attribute, mixed $value)

Set attribute.

attribute(string $attribute, mixed $value)

Fluent alias for setAttribute().

void
setAttributes(array $attributes)

Set all attributes.

attributes(array $attributes)

Fluent alias for setAttributes().

Details

mixed getAttribute(string $attribute, mixed $default = '')

Get attribute.

Parameters

string $attribute
mixed $default

Return Value

mixed

array getAttributes()

Get all attributes.

Return Value

array mixed>

void setAttribute(string $attribute, mixed $value)

Set attribute.

Parameters

string $attribute
mixed $value

Return Value

void

HasAttributesTrait attribute(string $attribute, mixed $value)

Fluent alias for setAttribute().

Parameters

string $attribute
mixed $value

Return Value

HasAttributesTrait $this

void setAttributes(array $attributes)

Set all attributes.

No attempt to merge attributes is done - this is a direct overwrite operation.

Parameters

array $attributes mixed> $attributes

Return Value

void

HasAttributesTrait attributes(array $attributes)

Fluent alias for setAttributes().

Parameters

array $attributes mixed> $attributes

Return Value

HasAttributesTrait $this