trait has_metadata

Trait has_metadata.

Provides EAV (Entity-Attribute-Value) access methods for Domain Items. Supports immutability via with_meta.

Magic Methods Support:

  • get_() : mixed
  • with_($value) : static

Properties

array<string,mixed> $metadata

Expected property on the consuming class.

Methods

mixed
__call(string $method, array $arguments)

Magic call handler for metadata getters and withers.

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

Retrieve a metadata value by key.

bool
has_meta(string $key)

Check if a metadata key exists.

array
get_all_meta()

Get all metadata.

with_meta(string $key, mixed $value)

Return a new instance with the updated metadata (Immutable).

with_all_meta(array $metadata)

Return a new instance replacing all metadata.

Details

at line 46
mixed __call(string $method, array $arguments)

Magic call handler for metadata getters and withers.

Allows accessing metadata like $item->get_price() or $item->with_price(10).

Parameters

string $method
array $arguments

Return Value

mixed

at line 79
mixed get_meta(string $key, mixed $default = null)

Retrieve a metadata value by key.

Parameters

string $key
mixed $default

Return Value

mixed

at line 95
bool has_meta(string $key)

Check if a metadata key exists.

Parameters

string $key

Return Value

bool

at line 109
array get_all_meta()

Get all metadata.

Return Value

array

at line 124
has_metadata with_meta(string $key, mixed $value)

Return a new instance with the updated metadata (Immutable).

Parameters

string $key
mixed $value

Return Value

has_metadata

at line 144
has_metadata with_all_meta(array $metadata)

Return a new instance replacing all metadata.

Parameters

array $metadata

Return Value

has_metadata